错误:执行任务'app:generateDebugBuildConfig'失败

5

错误:执行任务'app:generateDebugBuildConfig'失败

java.io.FileNotFoundException: C:\Users\bok\Desktop\Zipzap\app\build\generated\source\buildConfig\debug\com\storie\myapp \BuildConfig.java(指定的路径未找到)

解决方案是什么?

我希望能找到解决这个问题的方法。

6个回答

13

尝试清理项目,这对我有效

适用于安卓

$ cd android 

$ ./gradlew clean

BUILD SUCCESSFUL in 5s
1 actionable task: 1 executed

1
在我的终端中使用 ./gradelew clean 时,出现了 `'.' 不是内部或外部命令的错误提示。 - pratteek shaurya
使用 Ctrl + Enter 在 Android Studio 终端中运行命令 - Asef Hossini

2

更改端口对我有用

你可以尝试:

react-native run-android --port=8082


1
  1. 进入项目根目录。
  2. 进入android文件夹。 cd android
  3. 清除gradle缓存。 .\gradlew clean./gradlew clean 对我来说无法工作,原因不明。)
  4. 返回根目录。 cd ..
  5. 运行React Native。 npx react-native run-android

1
尝试清理并重建项目,或者您可以尝试删除整个构建文件夹,并在删除后进行构建。如果这样做无法解决问题,请展示您的build.gradle文件,您当前提供的信息不足以识别问题的原因。

1

React Native

在构建React Native应用程序时,遇到了类似的问题。默认端口(8081)被其他应用程序使用,因此需要在不同的端口上运行。

构建应用程序的命令。

react-native run-android --port=8082

解决方案

删除了额外的属性android:screenOrientation="portrait"。如果您检查日志,它会说:

lineNumber: 26; columnNumber: 56; Attribute "screenOrientation" bound to namespace "http://schemas.android.com/apk/res/android" was already specified for element "activity".

因此,删除了相同的属性。这个属性被添加了多次。

错误日志

Configure project :react-native-webview
:react-native-webview:reactNativeAndroidRoot /Users/PROJECT_PATH/node_modules/react-native/android

Task :app:generateDebugBuildConfig FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateDebugBuildConfig'.
org.xml.sax.SAXParseException; systemId: file:/Users/PROJECT_PATH/android/app/src/main/AndroidManifest.xml; lineNumber: 26; columnNumber: 56; Attribute "screenOrientation" bound to namespace "http://schemas.android.com/apk/res/android" was already specified for element "activity".

* 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 1s
32 actionable tasks: 1 executed, 31 up-to-date
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

Command failed: ./gradlew installDebug

screenshot of error


0

在Android Studio中,

  1. 在菜单栏中,选择 build
  2. 点击 clean project 并等待项目清理完成
  3. 然后再次在菜单栏中选择 build -> rebuild project 并等待项目重建完成。
  4. 就这样了

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接