Failed to notify project evaluation listener > javax/xml/bind/annotation/XmlSchema

Viewed 12937

I trying to first run an react-native app with react-native run-android. I expect it to work, like it does when I call react-native run-ios. Have a lot of users with same kind of error here on stack, "Failed to notify project evaluation listener".

Observed Behavior

> react-native run-android
Scanning folders for symlinks in /Users/tiagogouvea/www/go-along/mobile/node_modules (12ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.gradle.internal.reflect.JavaMethod (file:/Users/tiagogouvea/.gradle/wrapper/dists/gradle-4.0-milestone-1-all/2rnr7rhi2zsmkxo9re7615fy6/gradle-4.0-milestone-1/lib/gradle-base-services-4.0.jar) to method java.lang.ClassLoader.getPackages()
WARNING: Please consider reporting this to the maintainers of org.gradle.internal.reflect.JavaMethod
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /Users/tiagogouvea/Library/Android/sdk/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > javax/xml/bind/annotation/XmlSchema

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 4s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

Environment

  • npm ls react-native-scripts: empty
  • npm ls react-native: react-native@0.50.3
  • npm ls expo: empty
  • node -v: v8.0.0
  • npm -v: 5.5.1
  • yarn --version: 1.2.1
  • watchman version: 4.9.0

    1. Operating system: macOs 10.12.6
    2. Phone/emulator/simulator & version: Genymotion image
3 Answers

As mentioned in a comment to the bug filed by OP, Gradle seems to have issues with Java 9 or later.

You need to install JDK 8 (JRE is not enough, and versions later than 8 will not work) and tell Gradle to use it, not the default Java version on your system.

In my case (running Ubuntu 18.04), this required installing openjdk-8-jdk (I already had JDK 11 and JRE 8 but not JDK 8).

You have several ways of telling Gradle to use JDK 8 (in all examples, replace the path with the actual path to your JDK installation; the one shown here is valid for Ubuntu 18.04 amd64):

  1. Run Gradle with the option

    -Dorg.gradle.java.home=/usr/lib/jvm/java-8-openjdk-amd64
    
  2. Ensure ~/.gradle/gradle.properties contains the line

    org.gradle.java.home=/usr/lib/jvm/java-8-openjdk-amd64
    
  3. In your build.gradle include the following lines:

    compileJava.options.fork = true
    compileJava.options.forkOptions.executable = /usr/lib/jvm/java-8-openjdk-amd64
    

That has helped me get rid of the same error on a different project.

In fact I was running Java 9, running a java --version gave me:

$: java --version java 9 Java(TM) SE Runtime Environment (build 9+181) Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

To solve it completely I did:

1) Removed Java 9:

sudo rm -rf "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin"  
sudo rm -rf "/Library/PreferencePanes/JavaControlPanel.prefPane"  
sudo rm -rf "~/Library/Application Support/Java"

2) Installed back Java 8 - download here

3) Added JAVA_HOME line to my bashfile (~/.bash_profile):

nano ~/.bash_profile  
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

* Pay attention to use right jdk version on path

And, everything wokrs fine now. Thanks for help @user149408!

I've resolved this issue by cleaning all the Gradle cache, stoping the Gradle Daemon process, and created a new build successfully using the following command. Make sure your current directory is android.

rm -rf ~/.gradle/caches && ./gradlew --stop && ./gradlew cleanBuildCache && ./gradlew bundleRelease
Related