raj
raj

Reputation: 6094

Unable to build android with ionic due to JDK-9

I have an ionic 2.0.0-rc0 app and I want to build n android platform. When I run ionic run android , it fails in between. StackTrace-

   > ionic-hello-world@ build /home/raj/ionic/github
    > ionic-app-scripts build
    [07:46:11]  ionic-app-scripts 0.0.23
    [07:46:11]  build prod started ...
    [07:46:11]  clean started ...
    [07:46:11]  clean finished in 9 ms
    [07:46:11]  copy started ...
    [07:46:11]  ngc started ...
    [07:46:11]  lint started ...
    [07:46:11]  copy finished in 171 ms
    [07:46:12]  lint finished in 960 ms
    [07:46:26]  ngc finished in 15.36 s
    [07:46:26]  bundle prod started ...
    [07:46:34]  bundle prod finished in 8.27 s
    [07:46:34]  sass started ...
    [07:46:36]  sass finished in 1.67 s
    [07:46:36]  minify started ...
    [07:46:36]  cleancss started ...
    [07:46:36]  uglifyjs started ...
    [07:46:47]  uglifyjs finished in 10.80 s
    [07:46:47]  cleancss finished in 10.80 s
    [07:46:47]  minify finished in 10.80 s
    [07:46:47]  build prod finished in 36.12 s
    Running command: /home/raj/ionic/github/hooks/after_prepare/010_add_platform_class.js /home/raj/ionic/github

    :CordovaLib:compileDebugJavaWithJavac FAILED


    FAILURE: Build failed with an exception.
    Error: /home/raj/ionic/github/platforms/android/gradlew: Command      failed with exit code 1 Error output:
    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':CordovaLib:compileDebugJavaWithJavac'.
    > Could not create an instance of type com.sun.tools.javac.api.JavacTool.

I am using genymotion as emulator, even though I dont think that matters in this issue. Many solution to this problem is setting JAVA_HOME path. But I have set it, echo $JAVA_HOME > /usr/lib/jvm/java-9-openjdk-amd64 . I suspect this is a problem with gradle 2.1 and java-9 from this . I have been stuck on this for some time now, any help would be appreciated.

Upvotes: 0

Views: 2073

Answers (2)

raj
raj

Reputation: 6094

Stupid me thought it would be a great idea to try out JDK-9 when the great Oracle warned me not to . Removed it and installed JDK-8 , problem solved. Oracle did see my future.

Upvotes: 3

Ujjwal kaushik
Ujjwal kaushik

Reputation: 1686

 cordova platform update android
 ionic build android
 ionic run android

Try running these commands. Hope This will help you :)

Upvotes: -2

Related Questions