无法通知项目评估监听器>的javax / XML /结合/注解/的XmlSchema

时间:2017-11-18 12:09:47

标签: android android-studio gradle react-native android-sdk-tools

我尝试首先使用react-native run-android运行一个react-native应用程序。我希望它能够正常工作,就像我打电话给react-native run-ios时一样。 堆栈中有很多用户遇到同样的错误,“无法通知项目评估监听器”。

观察到的行为

> 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

环境

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

    1. 操作系统:macOs 10.12.6
    2. 手机/模拟器/模拟器&版本:Genymotion图片

2 个答案:

答案 0 :(得分:3)

正如OP对提交的bug的评论中所提到的,Gradle似乎在Java 9或更高版本中存在问题。

您需要安装JDK 8(JRE是不够的,8之后的版本不起作用)并告诉Gradle使用它,而不是系统上的默认Java版本。

在我的情况下(运行Ubuntu 18.04),这需要安装openjdk-8-jdk(我已经有JDK 11和JRE 8但不是JDK 8)。

您可以通过多种方式告诉Gradle使用JDK 8(在所有示例中,将路径替换为JDK安装的实际路径;此处显示的路径对Ubuntu 18.04 amd64有效):

  1. 使用选项

    运行Gradle
    -Dorg.gradle.java.home=/usr/lib/jvm/java-8-openjdk-amd64
    
  2. 确保~/.gradle/gradle.properties包含

    org.gradle.java.home=/usr/lib/jvm/java-8-openjdk-amd64
    
  3. build.gradle中包含以下内容:

    compileJava.options.fork = true
    compileJava.options.forkOptions.executable = /usr/lib/jvm/java-8-openjdk-amd64
    
  4. 这帮助我摆脱了不同项目的同样错误。

答案 1 :(得分:0)

事实上,我正在运行Java 9,运行java --version给了我

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

彻底解决,我做到了:

1)删除了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)重新安装Java 8-download here

3)在我的bash文件(〜/ .bash_profile)中添加了JAVA_HOME行:

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

*注意在路径上使用正确的jdk版本

而且,现在一切正常。感谢您的帮助@ user149408!