【问题标题】:React-native build error: Execution failed for task ':react-native-maps:prepareComAndroidSupportAppcompatV72301Library'. > Could not expand ZIPReact-native 构建错误:任务“:react-native-maps:prepareComAndroidSupportAppcompatV72301Library”执行失败。 > 无法展开 ZIP
【发布时间】:2016-12-09 15:45:17
【问题描述】:

我在 Windows 10 系统上创建了一个新的 react-native 项目,安装了 react-native-maps 包和 rnpm link,但是在启动项目时我收到了 Build failed 错误。

是什么导致了这个问题?

react-native init myapp
npm install react-native-maps --save
rnpm link
react-native run-android

版本

react-native-cli: 1.3.0
react-native: 0.39.1
node: v7.2.1
npm: 3.10.10

错误

JS server already running.
Running C:\Users\y\AppData\Local\Android\Sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:react-native-maps:compileLint
:react-native-maps:copyReleaseLint UP-TO-DATE
:react-native-maps:preBuild UP-TO-DATE
:react-native-maps:preReleaseBuild UP-TO-DATE
:react-native-maps:checkReleaseManifest
:react-native-maps:preDebugAndroidTestBuild UP-TO-DATE
:react-native-maps:preDebugBuild UP-TO-DATE
:react-native-maps:preDebugUnitTestBuild UP-TO-DATE
:react-native-maps:preReleaseUnitTestBuild UP-TO-DATE
:react-native-maps:prepareComAndroidSupportAppcompatV72301Library FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-maps:prepareComAndroidSupportAppcompatV72301Library'.
> Could not expand ZIP 'C:\Users\y\AppData\Local\Android\sdk\extras\android\m2repository\com\android\support\appcompat-v
7\23.0.1\appcompat-v7-23.0.1.aar'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 7.247 secs
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/android-setup.html

(node:8824) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read prop
erty 'message' of undefined
(node:8824) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are
not handled will terminate the Node.js process with a non-zero exit code.

【问题讨论】:

    标签: android node.js reactjs react-native react-native-android


    【解决方案1】:

    我遇到了这个问题。尝试在 Android Studio 中打开您的项目。右上角有一些通知,需要更新Android build-tools和platform-tools。

    【讨论】:

    • 将 gradle 从 2.2.3 更新到 2.14.1。问题解决了。
    【解决方案2】:

    我经常遇到这样的问题 这是窗户问题。据我了解,这是因为扩展 zip 需要花费太多时间并且构建器失败。 我已经通过将项目文件夹移动到 ssd 并将项目文件夹添加到我的防病毒软件的例外中来最小化此类警告

    只要多执行'react-native run-android',过段时间就会完成

    【讨论】:

    • 我在没有防病毒软件的干净 Windows 10 系统上使用 SSD(Samsung 850 Pro)和 6 核(12 线程)4.6 GHz Intel 处理器。会尝试运行多次,看能否解压成功
    • 有没有办法增加解压操作的超时时间?
    • 不知道。我还没有调查过这种深度重新执行 run-android 对我有用(每次我看到无法扩展的不同 ZIP)并且经过几次尝试构建成功,同时执行下一个 run-android 命令这个 ZIP 没有扩展所以问题是对我来说不重要
    【解决方案3】:

    你需要根据这个issue进行如下操作

    cd android && gradlew clean && cd .. && react-native run-android
    

    【讨论】:

    【解决方案4】:

    在窗户上

    cd android 
    gradlew clean 
    cd ..
    react-native run-android
    

    cd android && gradlew clean && cd .. && react-native run-android
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-11
      • 1970-01-01
      • 2022-11-08
      • 1970-01-01
      • 2020-07-08
      • 1970-01-01
      • 2021-07-09
      • 2020-08-11
      相关资源
      最近更新 更多