[TIMOB-25799] Android: Cannot build titanium project with JDK 1.9
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-04-02T19:43:27.000+0000 |
Affected Version/s | Release 7.1.0 |
Fix Version/s | Release 7.1.1 |
Components | Android |
Labels | n/a |
Reporter | Satyam Sekhri |
Assignee | Ewan Harris |
Created | 2018-02-23T01:41:34.000+0000 |
Updated | 2018-04-04T18:37:27.000+0000 |
Description
When the system has only jdk 9 installed then the titanium project fails to build for android.
Steps to Reproduce:
1. Create a default alloy project
2. build the project for android from command line "appc run -p android"
Actual Result:
The project does not build with following error:
[ERROR] Failed to run dexer:
[ERROR]
[ERROR] Error: Could not create the Java Virtual Machine.
[ERROR] Error: A fatal exception has occurred. Program will exit.
Running dexer manually shows the error is actually the following, in the dexer args [here](https://github.com/appcelerator/titanium_mobile/blob/d3cadc1bcecec20650fae421355e4edffa4876dd/android/cli/commands/_build.js#L4225) we need to swap '-Djava.ext.dirs=' + this.androidInfo.sdk.platformTools.path,
to '-classpath', this.androidInfo.sdk.platformTools.path
, I don't believe we need to handle this on a per-version basis as Java 1.8 handles the -classpath
arg just fine
-Djava.ext.dirs=/Users/eharris/Library/Android/sdk/platform-tools is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Can you run the
appc ti info -t jdk
command and see what it prints.If java home is not configured in the ti info, you can run the below command to configure the java home path.
Also, do this:
Verified on Windows OS. The issue occurs on Windows as well. Multiple JDK's can remain installed simulataneously. Hence on windows even if JDK 1.9 is installed but JAVA_HOME points to 1.8 version of JDK the build happens fine. As soon as the JAVA_HOME starts to point to JDK 1.9 the same issue is seen.
Interestingly the appc cli does have issue when using JDK1.9. The included terminal output below shows that despite of env. variable and ti config been set the "appc ti info -t jdk" does not find the jdk. If JAVA_HOME was set to JDK 1.8 then the appc cli finds the jdk even without setting the "appc ti config java.home" From Windows OS:
I believe this is due to TIMOB-25429, JDK 9 significantly changed the directory structure and consequently the SDK cannot detect it, the daemon can because we use the newer jdklib which handles it [commit](https://github.com/appcelerator/jdklib/commit/19b21f81301812ce93105619552c311c55e1b00a), it should be fairly simple to add these changes to node-appc, I was wary originally due to the Studio incompatability
I believe the issue is related to TIMOB-25429 as [~eharris] mentioned. With upcoming release of Studio to support JDK 9 it would be vital to support JDK 9 as well as the older ones in cli as well.
Made a PR to support JDK 9 detection, https://github.com/appcelerator/node-appc/pull/127, this only supports JDK 9 detection, I have not ran through tests in the SDK
Master: https://github.com/appcelerator/titanium_mobile/pull/9964 7_1_X: https://github.com/appcelerator/titanium_mobile/pull/9965
FR Passed. PR's merged.