Ionic build to Android Error


#1

Hi when I run ionic cordova run android I get this error:

(node:13788) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Requirements check failed for JDK 1.8 or greater


#2

What is your ionic info output?
What does ionic cordova requirements return?


#3
ionic info :

cli packages: (C:\Users\ybandar\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0 browser 5.0.3 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.9.4
    npm  : 5.6.0
    OS   : Windows 10

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

.
.
.

ionic cordova requirements:
> cordova requirements
Android Studio project detected


Requirements check results for android:

Java JDK: installed
Android SDK: installed true
Android target: not installed
cmd: Command failed with exit code 1 Error output:
Picked up _JAVA_OPTIONS: -Xmx20484m
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)
        at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
        ... 5 more
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-4.1\bin\gradle

Requirements check results for browser:
(node:13820) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'forEach' of undefined
(node:13820) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


#4

What version of Java JDK do you have installed?
Install the 1.8 one mentioned in the error message.


#5

Sorted out that problem, but got another one:

Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

#6

Open a new topic about that please. But I remember multiple older posts about this error.


#7

Solved everything, one not never try to run it within the integrated terminal of visual studio code


#8

Hi. I have the same problem but i (think) all installed!!

> ionic info
cli packages: (/usr/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 25.2.5
    Node              : v9.11.1
    npm               : 5.6.0 
    OS                : Linux 4.15

Environment Variables:

    ANDROID_HOME : /home/[USER]/android-sdk-linux/

Misc:

    backend : pro

> cordova requirements

Android Studio project detected

Requirements check results for android:
Java JDK: installed 
Android SDK: installed true
Android target: installed android-26,android-25
Gradle: installed /home/[USER]/gradle-4.7/bin/gradle
> java -version
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

> javac -version
javac 10.0.1

When i try build…

> ionic cordova build android

Running app-scripts build: --platform android --target cordova
[10:43:21]  build dev started ... 
[10:43:21]  clean started ... 
[10:43:21]  clean finished in 22 ms 
[10:43:21]  copy started ... 
[10:43:22]  copy finished in 319 ms 
[10:43:22]  deeplinks started ... 
[10:43:22]  deeplinks finished in 134 ms 
[10:43:22]  transpile started ... 
[10:43:29]  transpile finished in 7.25 s 
[10:43:29]  preprocess started ... 
[10:43:29]  preprocess finished in less than 1 ms 
[10:43:29]  webpack started ... 
[10:43:36]  webpack finished in 7.56 s 
[10:43:36]  sass started ... 
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[10:43:39]  sass finished in 2.08 s 
[10:43:39]  postprocess started ... 
[10:43:39]  postprocess finished in 12 ms 
[10:43:39]  lint started ... 
[10:43:39]  build dev finished in 17.66 s 
> cordova build android
Android Studio project detected

ANDROID_HOME=/home/[USER]/android-sdk-linux/
JAVA_HOME=/usr/lib/jvm/java-10-oracle
(node:2102) UnhandledPromiseRejectionWarning: CordovaError: Requirements check failed for JDK 1.8 or greater
   ...

What i have missed? :roll_eyes:


#9

I don’t believe it!! Donwgrade java 10 to java 8 and is, at this moment, compiling :open_mouth:
Days scratching my head… beginners suffers

BUILD SUCCESSFUL in 2m 13s
46 actionable tasks: 46 executed

#10

Awesome man…