【问题标题】:Build failed on run-android due to dependencies由于依赖关系,在 run-android 上构建失败
【发布时间】:2015-12-13 12:34:12
【问题描述】:

运行 run-android 时出现问题。我遇到了一个问题,我想这是 gradle 依赖项的问题。

我什至尝试过 sudo,它会给出其他一些随机错误,比如 $ANDROID_HOME。这不是问题。

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find com.android.support:appcompat-v7:23.0.0.
     Searched in the following locations:
         file:/Users/iraycd/.m2/repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
         file:/Users/iraycd/.m2/repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
         https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
         https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
     Required by:
         AwesomeProject:app:unspecified
   > Could not find com.android.support:appcompat-v7:23.0.0.
     Searched in the following locations:
         file:/Users/iraycd/.m2/repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
         file:/Users/iraycd/.m2/repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
         https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom
         https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.jar
     Required by:
         AwesomeProject:app:unspecified > com.facebook.react:react-native:0.11.0
   > Could not find com.android.support:support-v4:21.0.3.
     Searched in the following locations:
         file:/Users/iraycd/.m2/repository/com/android/support/support-v4/21.0.3/support-v4-21.0.3.pom
         file:/Users/iraycd/.m2/repository/com/android/support/support-v4/21.0.3/support-v4-21.0.3.jar
         https://jcenter.bintray.com/com/android/support/support-v4/21.0.3/support-v4-21.0.3.pom
         https://jcenter.bintray.com/com/android/support/support-v4/21.0.3/support-v4-21.0.3.jar
     Required by:
         AwesomeProject:app:unspecified > com.facebook.react:react-native:0.11.0 > com.facebook.fresco:fresco:0.6.1 > com.facebook.fresco:drawee:0.6.1
         AwesomeProject:app:unspecified > com.facebook.react:react-native:0.11.0 > com.facebook.fresco:fresco:0.6.1 > com.facebook.fresco:imagepipeline:0.6.1

* 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: 11.247 secs
Could not install the app on the device, see the error above.

我哪里做错了?

【问题讨论】:

  • 尝试更新Android SDK。似乎有新版本的库。更新远程存储库并重建

标签: android react-native


【解决方案1】:

【讨论】:

  • 部分包已重命名,尤其是“Android 支持库”似乎已重命名为“支持库的本地 Maven 库”。安装它为我修复了错误。
【解决方案2】:

如果像我一样,你读过的其他任何东西都没有用,这对我有用:

  1. 检查源代码管理更改的最新快照
  2. 从系统中删除项目目录
  3. 从源代码管理中检查您的代码
  4. npm cache clean && npm install
  5. watchman watch-del-all
  6. react-native start -- --reset-cache
  7. react-native run-android

:脑洞大开:

【讨论】:

    【解决方案3】:

    您似乎没有将机器上的库更新到最新版本。下载新版本的支持库/appcompat,然后重试

    【讨论】:

      【解决方案4】:

      您似乎没有安装 android sdk 和/或它的路径设置不正确。在 react native 的 android setup docs 中有详细的说明,请按照Install and configure SDK 的说明进行操作。

      【讨论】:

        【解决方案5】:

        对于那些在尝试简单地使用 Android SDK Manager (tools/android) 时遇到此问题的人,我必须以 root 身份运行 SDK 管理器(例如 sudo ./tools/android)来解决此错误。

        不幸的是,以 root 身份运行 X11 转发的程序有时会带来其自身的问题。如果您在尝试以 root 身份运行 SDK 管理器时遇到问题,请参阅this answer here。具体来说,我能够以普通用户身份运行 SDK 管理器,但尝试以 root 身份运行总是失败。

        【讨论】:

          【解决方案6】:

          您似乎没有安装 android sdk 和/或它的路径设置不正确。在 react native 的 android setup 文档中有详细的说明,请按照安装和配置 SDK 的说明进行操作。

          【讨论】:

            猜你喜欢
            • 2022-01-21
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2017-08-14
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多