Aman Maurya
Aman Maurya

Reputation: 1325

Unable to run the first time react-native app for android on mac

I'm trying to run the react-native application on the macbook for android version.So I have followed all the step for setting up the environment on the machine from here :

https://facebook.github.io/react-native/docs/getting-started.html

And I have successfully install Android Studio,Android SDK, JDK, Node, NPM, Watchman, Homebrew

When I tried to run the application with the command

react-native run-android

I got this error :

Starting JS server...
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/aman/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1/lib/gradle-base-services-2.14.1.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

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

Total time: 9.925 secs
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

enter image description here

Upvotes: 1

Views: 2019

Answers (3)

Rajan Maharjan
Rajan Maharjan

Reputation: 4982

Yes, according to @Sam Hanley it's an issue with the java version update. So, with worrying about the version update/downgrade, we can pass on with this issue by the following process;

  1. First, update the distributionUrl in gradle-wrapper.properties ie: located in this path;

PROJECT_PATH/android/gradle/wrapper/gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-rc-2-all.zip
  1. Set $JAVA_HOME environment variable using the installed android studio app path (Android studio should be installed)

export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"

(PS: solution for macOS )

Hope this help!

Upvotes: 1

zwessels
zwessels

Reputation: 637

I was able to get past this particular problem by doing the following:

  1. Edit path_to_your_project/android/gradlew
  2. Change DEFAULT_JVM_OPTS="" to DEFAULT_JVM_OPTS="--add-modules java.se.ee"

Upvotes: 0

Sam Hanley
Sam Hanley

Reputation: 4755

According to this GitHub issue, this issue has to do with JDK version. Make sure you're using v8, not v9, then the error should not occur.

Upvotes: 1

Related Questions