Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25799] Android: Cannot build titanium project with JDK 1.9

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-04-02T19:43:27.000+0000
Affected Version/sRelease 7.1.0
Fix Version/sRelease 7.1.1
ComponentsAndroid
Labelsn/a
ReporterSatyam Sekhri
AssigneeEwan Harris
Created2018-02-23T01:41:34.000+0000
Updated2018-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.

Comments

  1. Kondal Kolipaka 2018-02-23

    Can you run the appc ti info -t jdk command and see what it prints.
       $ appc  ti info -t jdk
       Appcelerator Command-Line Interface, version 6.2.1
       Copyright (c) 2014-2018, Appcelerator, Inc.  All Rights Reserved.
       
       Preproduction Environment Active
       
       Java Development Kit
         Version                     = 1.8.0_121
         Java Home                   = /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
       
    If java home is not configured in the ti info, you can run the below command to configure the java home path.
       $ appc ti config java.home /path/to/jdk
       
    Also, do this:
       

    OS X

    export JAVA_HOME=/path/to/jdk
  2. Satyam Sekhri 2018-02-23

    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.
  3. Satyam Sekhri 2018-02-23

    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:
       C:\Users\satyam>echo %JAVA_HOME%
       C:\Program Files\Java\jdk-9.0.4
       
       C:\Users\satyam>appc ti config
       Appcelerator Command-Line Interface, version 7.0.2
       Copyright (c) 2014-2018, Appcelerator, Inc.  All Rights Reserved.
       
       android.ndkPath            = "C:\\AndroidNDK\\android-ndk-r12b"
       android.sdkPath            = "C:\\android-sdk-win"
       app.workspace              = ""
       cli.colors                 = true
       cli.completion             = false
       cli.failOnWrongSDK         = false
       cli.httpProxyServer        = ""
       cli.ignoreDirs             = "^(\\.svn|_svn|\\.git|\\.hg|\\.?[Cc][Vv][Ss]|\\.bzr|\\$RECYCLE\\.BIN)$"
       cli.ignoreFiles            = "^(\\.gitignore|\\.npmignore|\\.cvsignore|\\.DS_Store|\\._.*|[Tt]humbs.db|\\.vspscc|\\.vssscc|\\.sublime-project|\\.sublime-workspace|\\.project|\\.tmproj)$"
       cli.logLevel               = "trace"
       cli.progressBars           = true
       cli.prompt                 = true
       cli.rejectUnauthorized     = true
       cli.width                  = 100
       genymotion.enabled         = true
       genymotion.path            = "C:\\Program Files\\Genymobile\\Genymotion"
       java.home                  = "C:\\Program Files\\Java\\jdk-9.0.4"
       paths.commands             = []
       paths.hooks                = ["C:\\Users\\satyam\\AppData\\Roaming\\Appcelerator\\Appcelerator Studio\\plugins\\com.appcelerator.titanium.liveview.core_1.1.0.1495386242\\node_modules\\liveview\\hook"]
       paths.modules              = []
       paths.plugins              = []
       paths.sdks                 = ["C:\\ProgramData\\Titanium"]
       paths.templates            = []
       sdk.defaultInstallLocation = "C:\\ProgramData\\Titanium"
       sdk.selected               = "7.1.0.v20180222163802"
       user.locale                = "en-us"
       windows.publisherId        = "CN=CAB0209E-F12D-48E4-BEF0-C6C965AB1083"
       
       C:\Users\satyam>appc ti info -t jdk
       Appcelerator Command-Line Interface, version 7.0.2
       Copyright (c) 2014-2018, Appcelerator, Inc.  All Rights Reserved.
       
       Java Development Kit
         Not found
       
       Java Development Kit Issues
         ×  JDK (Java Development Kit) not installed.
            If you already have installed the JDK, verify your JAVA_HOME environment variable is correctly
            set.
            The JDK is required for must be manually downloaded and installed from
            http://appcelerator.com/jdk.
       
       
  4. Ewan Harris 2018-02-23

    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
  5. Satyam Sekhri 2018-02-23

    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.
  6. Ewan Harris 2018-02-23

    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
  7. Ewan Harris 2018-03-28

    Master: https://github.com/appcelerator/titanium_mobile/pull/9964 7_1_X: https://github.com/appcelerator/titanium_mobile/pull/9965
  8. Lokesh Choudhary 2018-04-02

    FR Passed. PR's merged.
  9. Lokesh Choudhary 2018-04-04

JSON Source