React Native for Android中的依赖性错误

时间:2018-01-25 22:24:13

标签: android reactjs android-studio react-native react-native-android

我正在为Android编写React Native App。我用react-native-cli初始化了这个项目。当我尝试在Android上运行它时,我收到以下错误:

$ 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

我正在使用Ubuntu 16.04并安装了Android Studio 3.0.1。错误的原因是什么?

编辑:当我使用stacktrace,info和debug运行它时,我得到以下输出:

我无法在此处发布输出,因为它很长:pastebin

1 个答案:

答案 0 :(得分:1)

我通过将其添加到 .bashrc

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