vardump
vardump

Reputation: 658

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

When using react-native 0.28 and above (0.29, 0.30-rc), I get the following error when executing react-native run-android in a fresh react-native init app project.

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

I installed the newest android studio and even installed the obsolete library manually.

installed

What am I doing wrong? Thanks!

Upvotes: 7

Views: 5389

Answers (5)

Arnold Gandarillas
Arnold Gandarillas

Reputation: 4322

First solution could be adding this

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

to the next file

android/app/build.gradle

Second solution is installing Android Support Repository

Upvotes: 1

programmer
programmer

Reputation: 332

To Complete Tonithy's and Simon's answer, yes the jar itself was not enough, all the files of two directories -
extras/android/m2repository/com/android/support/support-v4/23.2.1/ and extras/android/m2repository/com/android/support/support-annotations/23.2.1/ are needed. On my Windows PC, I couldn't find files of these directories anywhere.

So what I did was, I downloaded these folders from googlesource

1. support/support-annotations/23.2.1

Download tgz of above folder and extract the files into {YOUR_ANDROID_LOCATION}/extras/android/m2repository/com/android/support/support-annotations/23.2.1/

2. support/support-v4/23.2.1

Download tgz of above folder and extract the files into {YOUR_ANDROID_LOCATION}/extras/android/m2repository/com/android/support/support-v4/23.2.1/

Now go to your command propmt or terminal and run react-native run-android

Hope it save someone few hours!!

Upvotes: 0

Simon
Simon

Reputation: 138

To complete Tonithy's answer - the .jar may not be enough, you need to copy two whole directories, otherwise gradle will complain for the missing .aar. In this case, I think that those were installed by Android Studio: {USER}/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.2.1/

And don't forget the dependency: {USER}/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.2.1/

I had exactly the same problem while upgrading to react-native 0.30, that solved the issue.

Upvotes: 7

Tonithy
Tonithy

Reputation: 2290

Google seems to have stopped including a version of each support library without sources/javadoc/etc and React is looking for this specific file. Assuming you manually installed the obsolete version, it will be in {YOUR_ANDROID_LOCATION}/extras/android/support/v4/android-support-v4.jar Your best bet is to manually copy it in:

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

This a React Native (version and probably OSX specific bug), it will probably be fixed soon. For posterity, your full error was something like this, looking for support in all the wrong places:

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

Upvotes: 5

Jagadish Upadhyay
Jagadish Upadhyay

Reputation: 1264

I also got this error, after installing Android Support Library the error has gone. Install Android Support Library from Extras

enter image description here

Upvotes: 3

Related Questions