【问题标题】:react-native run-android Building Error ':app:generateDebugBuildConfig'react-native run-android 构建错误':app:generateDebugBuildConfig'
【发布时间】:2017-12-26 14:16:06
【问题描述】:

我在构建新项目时遇到问题。我正在使用 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

这是提示的图像:Image of the problem

我该如何解决这个问题?

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

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

谢谢。

【问题讨论】:

标签: java android react-native build


【解决方案1】:

@diego-barreto

将值C:\....\AppData\Local\Android\sdk\tools 添加到变量Path 中,构建成功。问题解决了。耶。

【讨论】:

    【解决方案2】:

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

    gradlew clean // 运行这个

    【解决方案3】:

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

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

    然后从终端或cmd运行

    ./rn.sh
    

    推荐

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

    【讨论】:

      【解决方案4】:

      反应原生

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

      构建应用程序的命令。

      react-native run-android --port=8082

      解决方案 我的情况

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

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

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

      错误日志

      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
      

      【讨论】:

      • 这对我有帮助,但我不明白为什么错误消息与它与 android 无关但反应服务器这一事实令人困惑。
      【解决方案5】:

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

      gradlew cleanBuildCache

      然后启动 Android Studio 之类的工具进行构建,您应该会发现问题已解决。如果您仍然收到错误,请仔细检查日志,其中的信息很难找到。

      【讨论】:

        猜你喜欢
        • 2018-04-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多