【发布时间】:2020-09-05 13:54:22
【问题描述】:
当我运行“react-native run-android”或“npx react-native run-android”或“cd andriod ./gradlew clean”这些命令时,会显示错误
PS D:\work\Myproject-app> npx react-native run-android
info Starting JS server...
Starting a Gradle Daemon, 2 incompatible and 2 stopped Daemons could not be reused, use --status for details
> Configure project :app
Reading env from: .env
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
A problem occurred evaluating project ':app'.
> A problem occurred starting process 'command 'security''
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':app'.
> compileSdkVersion is not specified.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 19s
error 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/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
我也尝试使用最新版本的 Gradle!
操作系统 Windows 10 节点:14.2.0 Java:Java版本“1.8.0_251” Java(TM) SE 运行时环境 (build 1.8.0_251-b08) Java HotSpot(TM) 64 位服务器 VM(内部版本 25.251-b08,混合模式) Gradle 版本:5.1.1
JAVA_HOME、ANDROID_HOME 和添加到环境中的路径
【问题讨论】:
-
错误日志显示
compileSdkVersion is not specified。检查是否可以在 android/build.gradle 中添加compileSdkVersion -
感谢@B.Mohammad 的评论 :) 这是我的 android/build.gradle 的一些代码:
buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" firebaseVersion = "16.0.1" googlePlayServicesVersion = "16.0.1" } repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.3.0' } }
标签: react-native android-studio gradle build.gradle