简体   繁体   English

React Native for Android中的依赖性错误

[英]Dependency error in React Native for Android

I am writing a React Native App for Android. 我正在为Android编写React Native App。 I initialized the project with the react-native-cli. 我用react-native-cli初始化了这个项目。 When I try to run it on Android, I get the following error: 当我尝试在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

I am using Ubuntu 16.04 and I installed Android Studio 3.0.1. 我使用的是Ubuntu 16.04,我安装了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: 编辑:当我使用stacktrace,info和debug运行它时,我得到以下输出:

I can't post the output here, because it is to long: pastebin 我不能在这里发布输出,因为它是long: pastebin

I fixed it by adding this to .bashrc : 我通过将其添加到.bashrc来修复它:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为 React Native 创建原生 Android 模块时出现“依赖错误” - "Dependency error" while creating native Android module for React Native React Native:facebook-android-sdk依赖关系构建错误 - React Native: facebook-android-sdk dependency build error 依赖react-native-svg在android中不起作用 - Dependency react-native-svg is not working in android 反应原生android错误 - react native android error 添加 Facebook 依赖项会导致 React Native 出错 - Adding Facebook dependency gives error in React Native react-native-fb sdk com.android.support依赖性错误 - react-native-fb sdk com.android.support dependency error 使用 React Native 构建 Android 应用程序时出错:依赖项的 AAR 元数据中指定的 minCompileSdk (31) - Getting error while building Android app with React Native: The minCompileSdk (31) specified in a dependency's AAR metadata 安装对 android 的本机依赖项后,React Native Metro 捆绑器未连接 - React Native metro bundler not connecting after install a native dependency on android 将本机应用程序转换为本机 android 依赖项/库 - Converting react native app into native android dependency/library React Native Android中的JsonWebToken错误 - JsonWebToken error in react native android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM