【发布时间】:2018-07-05 07:02:47
【问题描述】:
我正在为 Android 编写一个 React Native 应用程序。我使用 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。错误的原因是什么?
编辑:当我使用堆栈跟踪、信息和调试运行它时,我得到以下输出:
我不能在这里发布输出,因为它太长了:pastebin
【问题讨论】:
-
> 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。
-
当你按照信息告诉你的去做时会发生什么?
-
感谢您的回答。我添加了一个指向输出的链接,其中包含信息、调试和堆栈跟踪 @Code-Apprentice
-
> 23:55:41.195 [错误] [org.gradle.BuildExceptionReporter] 原因:org.gradle.internal.resolve.ModuleVersionNotFoundException:找不到 com.android.tools.build:gradle: 3.0.1.
-
我将 build.gradle 中的版本更新为 2.2.3。但现在我收到以下错误:pastebin。似乎无法验证 SSL 加密。
标签: android reactjs android-studio react-native react-native-android