找不到com.android.support:support-v4:23.2.1

时间:2016-07-13 13:11:47

标签: react-native

当使用react-native 0.28及更高版本(0.29,0.30-rc)时,在新的react-native run-android项目中执行react-native init app时会出现以下错误。

Could not find com.android.support:support-v4:23.2.1.

我安装了最新的android工作室,甚至手动安装了过时的库。

installed

我做错了什么? 谢谢!

5 个答案:

答案 0 :(得分:7)

要完成Tonithy的回答 - .jar可能还不够,你需要复制两个完整的目录,否则gradle会抱怨丢失的.aar。在这种情况下,我认为这些是由Android Studio安装的: {USER}/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/

并且不要忘记依赖: {USER}/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.2.1/

升级到react-native 0.30时我遇到了完全相同的问题,解决了这个问题。

答案 1 :(得分:5)

谷歌似乎已经停止包含每个支持库的版本而没有sources / javadoc / etc,而React正在寻找这个特定的文件。假设您手动安装了过时的版本,它将在{YOUR_ANDROID_LOCATION}/extras/android/support/v4/android-support-v4.jar中。您最好的选择是手动将其复制到:

cp {YOUR_ANDROID_LOCATION}/extras/android/support/v4/android-support-v4.jar {YOUR_ANDROID_LOCATION}/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar

这是一个React Native(版本,可能是OSX特定的bug),很快就会修复。对于后代,你的完整错误是这样的,在所有错误的地方寻找支持:

OsagieTheGreat-MBA:somereactapp osagiethegreat$ react-native run-android
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:support-v4:23.2.1.
     Searched in the following locations:
         file:/Users/osagiethegreat/.m2/repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         file:/Users/osagiethegreat/.m2/repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
         https://jcenter.bintray.com/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         https://jcenter.bintray.com/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
         file:/Users/osagiethegreat/Documents/somereactapp/node_modules/react-native/android/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         file:/Users/osagiethegreat/Documents/somereactapp/node_modules/react-native/android/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
         file:/Applications/Android Dev/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         file:/Applications/Android Dev/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
         file:/Applications/Android Dev/sdk/extras/google/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         file:/Applications/Android Dev/sdk/extras/google/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
     Required by:
         SomeReactApp:app:unspecified > com.android.support:appcompat-v7:23.0.1
         SomeReactApp:app:unspecified > com.facebook.react:react-native:0.29.0 > com.android.support:recyclerview-v7:23.0.1
   > Could not find com.android.support:support-v4:23.2.1.
     Searched in the following locations:
         file:/Users/osagiethegreat/.m2/repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         file:/Users/osagiethegreat/.m2/repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
         https://jcenter.bintray.com/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         https://jcenter.bintray.com/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
         file:/Users/osagiethegreat/Documents/somereactapp/node_modules/react-native/android/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         file:/Users/osagiethegreat/Documents/somereactapp/node_modules/react-native/android/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
         file:/Applications/Android Dev/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         file:/Applications/Android Dev/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
         file:/Applications/Android Dev/sdk/extras/google/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.pom
         file:/Applications/Android Dev/sdk/extras/google/m2repository/com/android/support/support-v4/23.2.1/support-v4-23.2.1.jar
     Required by:
         SomeReactApp:app:unspecified > com.facebook.react:react-native:0.29.0 > com.facebook.fresco:imagepipeline-okhttp3:0.11.0 > com.facebook.fresco:imagepipeline:0.11.0
         SomeReactApp:app:unspecified > com.facebook.react:react-native:0.29.0 > com.facebook.fresco:fresco:0.11.0 > com.facebook.fresco:drawee:0.11.0
         SomeReactApp:app:unspecified > com.facebook.react:react-native:0.29.0 > com.facebook.fresco:imagepipeline-okhttp3:0.11.0 > com.facebook.fresco:imagepipeline:0.11.0 > com.facebook.fresco:imagepipeline-base:0.11.0

* 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: 10.838 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

答案 2 :(得分:3)

我也遇到了这个错误,安装Android支持库后错误消失了。 从Extras安装Android支持库

enter image description here

答案 3 :(得分:1)

第一个解决方案可能是添加此

    compile 'com.android.tools:sdklib:23.2.1'

到下一个文件

  

机器人/应用/的build.gradle

第二个解决方案是安装 Android支持存储库

答案 4 :(得分:0)

完成Tonithy和Simon的回答,是的,jar本身还不够,两个目录的所有文件 -
    extras/android/m2repository/com/android/support/support-v4/23.2.1/和    需要extras/android/m2repository/com/android/support/support-annotations/23.2.1/。在我的Windows PC上,我无法在任何地方找到这些目录的文件。

所以我做的是,我从googlesource

下载了这些文件夹

<强> 1。 support/support-annotations/23.2.1

下载上述文件夹的tgz并将文件解压缩到{YOUR_ANDROID_LOCATION}/extras/android/m2repository/com/android/support/support-annotations/23.2.1/

<强> 2。 support/support-v4/23.2.1

下载上述文件夹的tgz并将文件解压缩到{YOUR_ANDROID_LOCATION}/extras/android/m2repository/com/android/support/support-v4/23.2.1/

现在转到命令propmt或终端并运行react-native run-android

希望能节省几个小时!!