Could not find com.android.support:appcompat-v7:25.3.1
Asked Answered
D

8

24

I suddenly started getting this error when trying to build. This was all working a few weeks ago with no changes that I know of. The issue seems to be related to react-native-fbsdk, but looking through its build.gradle it does not list support.appcompat-v7.25.x. Any advice?

A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-fbsdk'.
   > Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugCompile'.
      > Could not find com.android.support:appcompat-v7:25.3.1.
        Searched in the following locations:
            file:/Users/a/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom
            file:/Users/a/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar
            https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom
            https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar

build.gradle

apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "___"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 22
        versionName "1.5.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        manifestPlaceholders = [manifestApplicationId: "___",
                                onesignal_app_id: "___",
                                onesignal_google_project_number: "___"]
        multiDexEnabled true
        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true
    }
    signingConfigs {
      release {
        storeFile file(MYAPP_RELEASE_STORE_FILE)
        storePassword MYAPP_RELEASE_STORE_PASSWORD
        keyAlias MYAPP_RELEASE_KEY_ALIAS
        keyPassword MYAPP_RELEASE_KEY_PASSWORD
      }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile project(':react-native-device-info')
    compile project(':react-native-code-push')
    compile project(':react-native-image-crop-picker')
    compile project(':react-native-image-picker')
    compile project(':react-native-fs')
    compile project(':react-native-vector-icons')
    compile project(':react-native-material-kit')
    compile project(':react-native-config')
    compile project(':react-native-onesignal')
    compile project(':react-native-push-notification')
    compile project(':react-native-android-permissions')
    compile project(':react-native-android-keyboard-adjust')
    compile project(':react-native-fbsdk')
    compile (project(':react-native-fbads')) {
      exclude group: 'com.google.android.gms'
    }
    compile 'com.facebook.android:audience-network-sdk:4.18.+'
    compile 'com.google.ads.mediation:facebook:4.18.+'
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.google.firebase:firebase-crash:10.2.0'
    compile 'com.google.firebase:firebase-ads:10.2.0'
    compile project(':react-native-billing')
    compile project(':react-native-blur')
    compile project(':instabug-reactnative')
    compile project(':mobile-center-analytics')
    compile project(':mobile-center-crashes')
    compile (project(':react-native-appodeal')) {
      exclude group: 'com.facebook.ads'
      exclude (group: 'javax.inject', module: 'javax.inject')
    }
    compile project(':cheetah')

    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile "com.facebook.fresco:animated-gif:0.12.0"
    compile "com.android.support:multidex:1.0.1"
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply plugin: 'com.google.gms.google-services'
Decimal answered 27/5, 2017 at 5:10 Comment(4)
put your gradle fileCrack
Try ./gradlew --refresh-dependenciesBurnet
Did you manage to resolve the issue? I have the same thing happening and none of the suggested answers of this question resolve itVescuso
@MindaugasJačionis Yes I just figured it out for my case. Posted an answer.Decimal
E
16

I've had the same problem (appcompat-v7:25.3.1), on an android project, but not using react.

I first tried to clean the gradle cache (~/.gradle/caches), like explained here, but it didn't help.

Then I looked at the SDK Manager.
Android Support libraries are normally installed via sdkmanager. The libraries are then stored in a local maven repository : <SDK_HOME>/sdk/extras/android/m2repository/.

For example, for appcompat-v7 the list of versions installed is in <SDK_HOME>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/maven-metadata.xml.
So, for the Android Support Repository (revision: 47.0.0), the last version was normally 25.3.1.

To fix my problem, I had to uninstall the Android Support Repository via the SDK Manager, then reinstall it.

I also found another way to fetch support libraries : remotely. After reading here (https://developer.android.com/topic/libraries/support-library/setup.html#add-library) and modifying <PROJECT_ROOT>/build.gradle like this :

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

Then I tried to use a newer version of appcompat-v7:25.4.0 that was not in my local maven repository, and it worked !
The list of this Google Maven repository's versions of this library can be seen there : https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/maven-metadata.xml.

Entrechat answered 15/6, 2017 at 19:44 Comment(0)
C
13

Follow the steps,

  1. Add google maven in project gradle (Project: build.gradle),

    allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } }

  2. Remove existing gradle cache with below command

    rm -fr ~/.gradle/caches/

  3. Have a clean build and run
Capreolate answered 4/7, 2019 at 7:4 Comment(1)
This should be the correct and simplest answer. for me this was not needed:rm -fr ~/.gradle/caches/Leaven
D
6

My case was that this is react-native-fbsdk build.gradle (https://github.com/facebook/react-native-fbsdk/blob/master/android/build.gradle):

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
    compile('com.facebook.android:facebook-android-sdk:4.+')
}

I am using React Native 0.37, so this is the line that broke for me:

compile('com.facebook.android:facebook-android-sdk:4.+')

Had to change to this for compatibility:

compile('com.facebook.android:facebook-android-sdk:4.18.+')
Decimal answered 30/5, 2017 at 2:44 Comment(1)
Thanks, this was precisely my issue too, and I'm back on React Native 0.22.Scorpaenid
P
2

For this, try one of the following option:

1. Update your SDK manager > Go to build menu > clean project > then build project

or

2. Right click on project folder > open module setting > libraries > add com.android.support:appcompat-v7:25.3.1 > sync the project

3. Click on file menu > open project structure > and file the libraries

Purgation answered 27/5, 2017 at 5:21 Comment(6)
I have the same problem. I can't find com.android.support:appcompat-v7:25.3.1 i.imgur.com/cqPtiSg.pngGambrel
Follow any of the above options.Purgation
I tried all but failed. Please see the attached picture: i.imgur.com/o0nEdgj.png and above picture.Gambrel
I found the problem and resloved. Link: developer.android.com/topic/libraries/support-library/…Gambrel
I actually get the same error when I run ./gradlew clean. @MítTơLớp What is the actual line that you changed?Decimal
@roachman, In that picture mentioned attached by Mít Tơ Lớp just dive into Build, Execution and Deployment.Purgation
G
0

This seems to be an issue with react-native itself. There is no official fix for this (yet), however some people have reported upgrading to have solved their problem. You can check more details here

Update 1: Hi @roachman, this is the exact error I got which pointed me to search for above. There is another ticket logged #14225 for same(cannot post link for some reason). I was just able to resolve it by including exact version of react-native version in build.gradle dependencies line compile "com.facebook.react:react-native:0.xx.y" instead of compile 'com.facebook.react:react-native:+' You might want to try that for all projects that use that setting or a more elegant settings suggested in above in issue #14223 by user david50407

Update 2 This is officially fixed now have a look https://github.com/facebook/react-native/issues/14225#issuecomment-305073392 (had to remove earlier link for issue 14223 as I cannot post more than 2 links)

Goldengoldenberg answered 29/5, 2017 at 11:0 Comment(1)
This does not seem to be the same problem I am getting.Decimal
S
0

To solve this problem:

  1. Open package.json and edit the react version to:

    "react": "16.0.0-alpha.3", "react-native": "0.43.1",

  2. Delete node_modules directory

  3. And re-install npm with the command npm install

  4. In Addition: If you get a app:compileDebugJava ERROR, run react-native upgrade

(Got the solution from this github page and it worked for me)

Salep answered 29/5, 2017 at 12:45 Comment(1)
Cool, but I am stuck on React Native 0.37. I feel like it shouldn't suddenly just break like this.Decimal
L
0

Since gradle doesn't support declaring repositories on a per-artifact basis yet.

I modified my build.gradle (not app/build.gradle) to force all dependency to react-native to specific version:

allprojects {
     configurations.all {
       resolutionStrategy {
         eachDependency { DependencyResolveDetails details ->
           if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
                def file = new File("$rootDir/../node_modules/react-native/package.json")
                def version = new groovy.json.JsonSlurper().parseText(file.text).version
                details.useVersion version
           }
         }
       }
     }
  }
Limey answered 30/5, 2017 at 9:19 Comment(1)
There's a slightly nicer version of this in the github issue github.com/facebook/react-native/issues/14223 that reads your actual react-native version from the installed node_modules so you don't have to update in two places.Moribund
F
0

If you upgraded react-native-fbsdk from 0.5 to 0.6 versions and have this issue then open your android project (pathToYourApp/android) in Android Studio and it automatically offers you to update dependencies. Now It should work fine!

Forwarding answered 6/6, 2017 at 19:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.