Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19400] Android: Build fails if Java 1.6 is not installed

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-08-31T22:19:11.000+0000
Affected Version/sRelease 4.1.0
Fix Version/sRelease 5.0.0
ComponentsAndroid, Tooling
Labelsqe-4.1.0
ReporterLokesh Choudhary
AssigneeChris Barber
Created2015-06-25T23:05:24.000+0000
Updated2015-09-30T18:54:47.000+0000

Description

Description:

1. On a clean machine setup appcelerator studio. 2. Studio will download java 1.7.0_XX, node js & appc CLI. 3. Login to studio & download android SDK from with in studio. 4. Create an app & run it on android device/emulator.

Actual Results:

1. The build fails as it looks for java 1.6 & errors as it can't find it with the errors below:
[INFO]  Encrypting JavaScript files: /Users/qetester/Library/Application Support/Titanium/mobilesdk/osx/4.0.0.GA/android/titanium_prep.macos "com.app.test1" "/Users/qetester/Documents/Appcelerator_Studio_Workspace/test1/build/android/assets" "alloy/CFG.js" "app.js" "alloy/backbone.js" "alloy/constants.js" "alloy/controllers/BaseController.js" "alloy/controllers/index.js" "alloy/styles/index.js" "alloy/sync/localStorage.js" "alloy/sync/properties.js" "alloy/sync/sql.js" "alloy/underscore.js" "alloy/widget.js" "alloy.js" "ti.cloud.js" "_app_props_.json"
[ERROR] Failed to encrypt JavaScript files
[ERROR] No Java runtime present, requesting install.
 
TRACE  | titanium exited with exit code 1
ERROR  | Error: ti run exited with error code 1
    at ChildProcess.<anonymous> (/Users/qetester/.appcelerator/install/4.0.2/package/node_modules/appc-cli-titanium/plugins/run.js:84:66)
    at ChildProcess.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:820:12)
2. We also get a dialog saying "This application needs java 6" & clicking on more info button on the dialog it takes us to the java 1.6 download page on apple's website. *NOTE* - Attached screenshot for reference.

Expected Result:

1. The build should succeed with java 1.7.0_X.

Attachments

FileDateSize
Screen Shot 2015-06-25 at 3.58.30 PM.png2015-06-25T23:07:15.000+000026044

Comments

  1. Dan Wilson 2015-08-02

    I'm running into this issue as well. I recently upgraded to El Capitan DP5. Previously, I just installed the second version of Java (which is pretty lame to have 2 versions on your system). But El Cap doesn't have Java 1.6. I even tried the --skip-js-minify, but that doesn't help either.
       Operating System
         Name                        = Mac OS X
         Version                     = 10.11
         Architecture                = 64bit
         # CPUs                      = 8
         Memory                      = 17179869184
       
       Node.js
         Node.js Version             = 0.10.37
         npm Version                 = 1.4.28
       
       Titanium CLI
         CLI Version                 = 4.1.3
       
       Titanium SDK
         SDK Version                 = 4.1.0.GA
         SDK Path                    = /Users/danwilson/Library/Application Support/Titanium/mobilesdk/osx/4.1.0.GA
         Target Platform             = android
       
       Command
         /usr/local/bin/node /Users/danwilson/git/ultimatehang/node_modules/grunt-titanium/node_modules/.bin/titanium build --log-level info --platform android --project-dir . --no-banner --no-progress-bars --no-prompt --build-only --deploy-type production --target dist-playstore --keystore ~/Documents/Codeality/Ultimate Hang/Keystore/UltimateHang --store-password **** --alias UltimateHang --output-dir /Users/danwilson/tmp --skip-js-minify
       
  2. Dan Wilson 2015-08-02

    Just realized I didn't add the actual error:
       INFO] :   Processing JavaScript files
       [INFO] :   Encrypting JavaScript files: /Users/danwilson/Library/Application Support/Titanium/mobilesdk/osx/4.1.0.GA/android/titanium_prep.macos "com.codeality.UltimateHang" "/Users/danwilson/git/ultimatehang/build/android/assets" "app.js" "lib/Hang.js" "lib/WindowAnim.js" "lib/lodash.min.js" "ui/AboutView.js" "ui/AboutWindow.js" "ui/ApplicationWindow.js" "ui/ClinometerView.js" "ui/ClinometerWindow.js" "ui/MainView.js" "ui/QuickstartView.js" "ui/QuickstartWindow.js" "ui/SettingsView.js" "ui/SettingsWindow.js" "ti.cloud.js" "_app_props_.json"
       [ERROR] :  Failed to encrypt JavaScript files
       [ERROR] :  JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bundle/Libraries/libserver.dylib
       [ERROR] :  JavaVM FATAL: Failed to load the jvm library.
       [ERROR] :  Program launch failed.
       
  3. Chris Barber 2015-08-29

    node-appc PR: https://github.com/appcelerator/node-appc/pull/111
  4. Chris Barber 2015-08-31

    node-appc PR 2: https://github.com/appcelerator/node-appc/pull/112
  5. Chris Barber 2015-08-31

    tisdk PR: https://github.com/appcelerator/titanium_mobile/pull/7102
  6. Chris Barber 2015-08-31

    After a bunch of testing and research, I've concluded that titanium_prep uses certain JNI APIs that are only available in JDK 1.6. They do not exist in 1.7 or 1.8. I tried changing how titanium_prep links with the JDK, but the result was always the same. So, I've greatly improved node-appc's JDK detection code to find all JDKs, then implemented a check in the Android build to ensure JDK 1.6 is installed when building on OS X. About as good as it gets.
  7. Dan Wilson 2015-08-31

    I'm not sure this is a proper solution. It's my understanding that JDK 1.6 will not be supported going forward. It's not available from Oracle and Apple is discontinuing support in El Cap. So checking to ensure it is installed won't do us any good if there is no way to get it installed in the (near) future.
  8. Ingo Muschenetz 2015-08-31

    We can't replace these APIs with alternates?
  9. Chris Barber 2015-08-31

    [~killroyboy] I know. This is not ideal. We have a replacement for titanium_prep which will be remove this dependency on JDK 1.6, however it currently requires the Appcelerator CLI and it requires that all users of your app have an Internet connection when the app is first launch. You can read more about this here: https://docs.appcelerator.com/platform/latest/#!/guide/tiapp.xml_and_timodule.xml_Reference (search for "appc-sourcecode-encryption-policy"). [~ingo] Nope. The JNI APIs we need have been deprecated. No idea when they'll be removed, but they are still present in Java 1.8's headers. There's nothing that we can easily do aside from a major rewrite of titanium_prep... or I suppose we could distribute the JDK 1.6 with Titanium. Probably a bad idea. I think the correct solution here is to rewrite titanium_prep using a combination of Node.js and C++. The overall architecture would be essentially the same.
  10. Chris Barber 2015-09-03

    node-appc PR 3: https://github.com/appcelerator/node-appc/pull/113
  11. Chris Barber 2015-09-03

    TiSDK master PR 2: https://github.com/appcelerator/titanium_mobile/pull/7122 TiSDK 5_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/7123
  12. Lokesh Choudhary 2015-09-10

    Verified the fix on a clean machine. If you don't have java 1.6 the build fails & the error logs has the link to download java 1.6. Installing java 1.6 from the link fixes the issue & the android build are successfull. Closing. Environment: Appc studio : 4.1.1.201507141126 Ti SDK : 5.0.0.v20150910052019 Appc NPM : 4.1.1 Appc Core : 4.1.3 Mac Yosemite : 10.10.4 Android Device : Nexus 5.1.1 Node : 0.10.37
  13. Chris Barber 2015-09-30

    [~cwilliams] On OS X, we do not dlopen() the jvm library. It's dynamically linked at compile time. I converted titanium_prep to use the same code path as Linux and Windows so that it used dlopen() to dynamically link at runtime and had the exact same results.

JSON Source