找不到com.android.support:appcompat-v7:25.3.1

atk*_*yla 13 android fbsdk react-native-android react-native-fbsdk

我在尝试构建时突然开始出现此错误.几周前这一切都在运作,我所知道的没有任何变化.这个问题似乎与此有关react-native-fbsdk,但通过它的build.gradle查看它没有列出support.appcompat-v7.25.x.有什么建议?

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
Run Code Online (Sandbox Code Playgroud)

的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'
Run Code Online (Sandbox Code Playgroud)

Saz*_*han 10

按照步骤,

  1. 在项目 gradle ( Project: build.gradle) 中添加 google maven ,

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

  2. cache使用以下命令删除现有的 gradle

    rm -fr ~/.gradle/caches/

  3. 有一个干净的构建和运行


Gui*_*sta 7

我在Android项目上遇到了同样的问题(appcompat-v7:25.3.1),但没有使用react.

我第一次尝试清理缓存的gradle(〜/ .gradle /高速缓存),如解释在这里,但它并没有帮助.

然后我查看了SDK Manager.
Android支持库通常通过sdkmanager安装.然后将这些库存储在本地maven存储库中:<SDK_HOME>/sdk/extras/android/m2repository/.

例如,对于appcompat-v7安装的版本列表<SDK_HOME>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/maven-metadata.xml.
因此,对于Android支持存储库(版本:47.0.0),最后一个版本通常为25.3.1.

为了解决我的问题,我不得不通过SDK Manager 卸载 Android Support Repository,然后重新安装它.

我还找到了另一种获取支持库的方法:远程.在这里阅读(https://developer.android.com/topic/libraries/support-library/setup.html#add-library)并修改<PROJECT_ROOT>/build.gradle如下:

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我尝试使用更新版本的appcompat-v7:25.4.0,它不在我当地的maven存储库中,并且它有效!
可以在此处查看此Google Maven存储库的此库版本列表:https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/maven-metadata.xml.


atk*_*yla 6

我的情况是这是react-native-fbsdkbuild.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.+')
}
Run Code Online (Sandbox Code Playgroud)

我正在使用React Native 0.37,所以这就是为我打破的界限:

compile('com.facebook.android:facebook-android-sdk:4.+')
Run Code Online (Sandbox Code Playgroud)

为了兼容性,不得不改为此:

compile('com.facebook.android:facebook-android-sdk:4.18.+')
Run Code Online (Sandbox Code Playgroud)


小智 2

为此,请尝试以下选项之一:

1.更新您的SDK manager> 转到构建菜单 > clean project> 然后build project

或者

2.右键单击项目文件夹>打开module setting>>libraries添加com.android.support:appcompat-v7:25.3.1>sync项目

3.单击file菜单 > 打开project structure> 并归档libraries