繁体   English   中英

react-native run-android 构建错误 ':app:generateDebugBuildConfig'

[英]react-native run-android Building Error ':app:generateDebugBuildConfig'

我在构建新项目时遇到问题。 我正在使用 React-Native 和 Android Emulator (AVD),但是当我使用命令react-native run-android我收到以下消息:

FAILURE:构建失败,出现异常。

* 出了什么问题:

任务“:app:generateDebugBuildConfig”执行失败。

> java.io.IOException: 无法删除路径“C:\\Users\\diego\\Desktop\\Diego\\albums\\android\\app\\build\\generated\\source\\buildConfig\\debug\\com”。

* 尝试:

使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获得更多日志输出。

构建失败

总时间:2 分 47.189 秒

无法在设备上安装该应用程序,请阅读上面的错误以了解详细信息。 确保您有一个正在运行的 Android 模拟器或已连接的设备并已设置您的 Android 开发环境:https ://facebook.github.io/react-native/docs/android-setup.html

这是提示的图像:问题的图像

我该如何解决这个问题?

-------------------------------------------------- -----------更新------------------------------ -----------------

我将值C:\\....\\AppData\\Local\\Android\\sdk\\tools到变量Path并且构建成功。 问题解决了。 耶。

谢谢。

@迭戈-巴雷托

将值C:\\....\\AppData\\Local\\Android\\sdk\\tools到变量Path并且我构建成功。 问题解决了。 耶。

cd android //从根目录导航到android文件夹

gradlew clean // 运行这个

在 React Native 项目的根目录中创建rn.sh文件,内容如下

 cd android/app/
 rm -rf build
 cd ..
 cd ..
react-native run-android

然后从终端或cmd运行

./rn.sh

推荐

VSCode 必须以管理员身份运行或GitDesktop必须以管理员身份运行

反应本机

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

构建应用程序的命令。

react-native run-android --port=8082

解决我的情况下,

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

行号:26; 列数:56; 已为元素“activity”指定了绑定到命名空间“ http://schemas.android.com/apk/res/android ”的属性“screenOrientation”。

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

错误日志

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

错误截图

导航到 react-native 项目的 android 文件夹并键入以下内容:

gradlew cleanBuildCache

然后启动类似 Android Studio 的构建,您应该会发现问题已解决。 如果您仍然遇到错误,请仔细检查日志,那里的信息很难找到。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM