William M.
William M.

Reputation: 379

Dependency error in React Native for Android

I am writing a React Native App for Android. I initialized the project with the react-native-cli. When I try to run it on Android, I get the following error:

$ react-native run-android

Scanning folders for symlinks in /path/to/myreactnativeproject/node_modules (6ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

 FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'myreactnativeproject'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
     https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
     https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
     :myreactnativeproject:unspecified

* 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: 11.226 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

I am using Ubuntu 16.04 and I installed Android Studio 3.0.1. What is the reason for the error?

Edit: When I run it with stacktrace, info and debug, I get the following output:

I can't post the output here, because it is to long: pastebin

Upvotes: 3

Views: 543

Answers (1)

William M.
William M.

Reputation: 379

I fixed it by adding this to .bashrc:

export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
export PATH=$JAVA_HOME/bin:$PATH

Upvotes: 1

Related Questions