android - 构建React Native应用失败:任务:app:generateDebugBuildConfig FAILED

标签 android react-native gradle

我正在尝试在Android模拟器上运行应用程序。我按照React Native文档中的说明安装了Android Studio并设置了环境变量。我可以使用'''npx react-native init'''创建一个默认项目,然后运行它而不会出现问题,因此我猜我的安装很好。我克隆了存储库“已安装npm”,并遇到以下错误,尝试构建也失败。由于我是React Native的新手,并且到目前为止还没有参与该项目,所以我对如何进行此工作一无所知。

PS C:\Users\PP\pp-app> npm install
npm WARN aws-amplify-react-native@2.2.3 requires a peer of graphql@0.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN aws-amplify-react-native@2.2.3 requires a peer of react-native-fs@^2.12.1 but none is installed. You must install peer dependencies yourself.
npm WARN aws-amplify-react-native@2.2.3 requires a peer of react-native-sound@^0.10.9 but none is installed. You must install peer dependencies yourself.
npm WARN aws-amplify-react-native@2.2.3 requires a peer of react-native-voice@^0.2.6 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react@7.12.4 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react-native@3.6.0 requires a peer of eslint@^3.17.0 || ^4 || ^5 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-elements@0.19.1 requires a peer of react-native-vector-icons@^4.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-qrcode-scanner@1.2.3 requires a peer of react-native-camera@^1.0.2 but none is installed. You must install peer dependencies yourself.

audited 953593 packages in 10.847s
found 40843 vulnerabilities (39913 low, 930 moderate)
  run `npm audit fix` to fix them, or `npm audit` for details
PS C:\Users\PP\pp-app> npx react-native run-android
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  - amazon-cognito-identity-js (to unlink run: "react-native unlink amazon-cognito-identity-js")
  - react-native-camera (to unlink run: "react-native unlink react-native-camera")
  - react-native-linear-gradient (to unlink run: "react-native unlink react-native-linear-gradient")
  - react-native-vector-icons (to unlink run: "react-native unlink react-native-vector-icons")
  - react-native-webview (to unlink run: "react-native unlink react-native-webview")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your 
app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1054 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
Downloading https://services.gradle.org/distributions/gradle-4.10.1-all.zip
...............................................................................................................

Welcome to Gradle 4.10.1!

Here are the highlights of this release:
 - Incremental Java compilation by default
 - Periodic Gradle caches cleanup
 - Gradle Kotlin DSL 1.0-RC6
 - Nested included builds
 - SNAPSHOT plugin versions in the `plugins {}` block

For more details see https://docs.gradle.org/4.10.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

> Configure project :react-native-auth0
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.

> Transform okhttp-urlconnection.jar (com.squareup.okhttp3:okhttp-urlconnection:3.12.1) with JetifyTransform
ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}'
ERROR: [TAG] Failed to resolve variable '${project.groupId}'
ERROR: [TAG] Failed to resolve variable '${project.version}'
ERROR: [TAG] Failed to resolve variable '${project.groupId}'
ERROR: [TAG] Failed to resolve variable '${project.version}'
ERROR: [TAG] Failed to resolve variable '${project.groupId}'
ERROR: [TAG] Failed to resolve variable '${project.version}'
ERROR: [TAG] Failed to resolve variable '${project.groupId}'
ERROR: [TAG] Failed to resolve variable '${project.version}'

> Task :@react-native-community_async-storage:compileDebugJavaWithJavac

> Task :amazon-cognito-identity-js:compileDebugJavaWithJavac

> Task :app:generateDebugBuildConfig FAILED
66 actionable tasks: 56 executed, 10 up-to-date
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. 
3 warnings
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. 
3 warnings

FAILURE: Build failed with an exception.

* What went wrong:
java.io.IOException: Unable to delete directory C:\Users\PP\pp-app\android\app\build\generated\source\buildConfig\debug\com.
> Unable to delete directory C:\Users\PP\pp-app\android\app\build\generated\source\buildConfig\debug\com.

* 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 2m 33s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings

FAILURE: Build failed with an exception.

* What went wrong:
java.io.IOException: Unable to delete directory C:\Users\PP\pp-app\android\app\build\generated\source\buildConfig\debug\com.
> Unable to delete directory C:\Users\PP\pp-app\android\app\build\generated\source\buildConfig\debug\com.

* 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 2m 33s

    at checkExecSyncError (child_process.js:629:11)
    at execFileSync (child_process.js:647:13)
    at runOnAllDevices (C:\Users\PP\pp-app\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
    at buildAndRun (C:\Users\PP\pp-app\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at then.result (C:\Users\PP\pp-app\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

最佳答案

我遇到了同样的问题。当我将JDK更新为14和gradle版本3.6时,问题已自行解决。另外我还必须删除android文件夹中的build文件夹,运行命令

npx react-native run-android

它帮助了我。希望它也能解决您的问题。

关于android - 构建React Native应用失败:任务:app:generateDebugBuildConfig FAILED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60742415/

相关文章:

gradle tar 任务未执行

java - Android 项目构建失败 javax/xml/stream/events/StartElement.class

Android ListView 在数据下载之前加载 - 必须重新启动 View

javascript - 找不到 play-services-tasks-license.aar (com.google.android.gms :play-services-tasks-license:11. 8.0)

android - 后退按钮在 actionBar 中不起作用

android - 使用 Realm for android 将 RealmList<Object> 设置为我的数据库项

react-native - React Native共享方法多窗口

javascript - React Native - 获取 POST 不起作用

android - 如何在本地修改中使用Gradle依赖项?

java - react native : Volume Button Should Only Control Media (Android)