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

前端 未结 8 1942
名媛妹妹
名媛妹妹 2020-12-29 06:16

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

相关标签:
8条回答
  • 2020-12-29 07:00

    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.

    0 讨论(0)
  • 2020-12-29 07:00

    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
               }
             }
           }
         }
      }
    
    0 讨论(0)
提交回复
热议问题