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

时间:2017-05-27 05:10:35

标签: android react-native-android fbsdk 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

的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'

8 个答案:

答案 0 :(得分:7)

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

我首先尝试清理gradle缓存(〜/ .gradle / caches),如解释here,但它没有帮助。

然后我查看了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管理器卸载 Android支持存储库,然后重新安装

我还找到了另一种获取支持库的方法:远程。 在这里阅读(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"
        }
    }
}

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

答案 1 :(得分:6)

我的理由是这是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.+')
}

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

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

为了兼容性,必须改为:

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

答案 2 :(得分:0)

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

1。更新SDK manager&gt;转到构建菜单&gt; clean project&gt;然后build project

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

3。点击file菜单&gt;打开project structure&gt;并提交libraries

答案 3 :(得分:0)

这似乎是本身反应本身的问题。 目前还没有官方解决方案,但是有些人报告升级已经解决了他们的问题。您可以查看更多详细信息here

更新1: 嗨@roachman,这是我得到的确切错误,它指向我搜索上面。另一张票据记录#14225相同(由于某种原因无法发布链接)。我只能通过在build.gradle依赖行[{1}}而不是compile "com.facebook.react:react-native:0.xx.y"中包含确切版本的react-native版本来解析您可能想要尝试对于使用该设置的所有项目或用户david50407在问题#14223中建议的更优雅的设置

更新2 这是正式修复现在看看https://github.com/facebook/react-native/issues/14225#issuecomment-305073392(由于我无法发布超过2个链接,因此必须删除问题14223的早期链接)

答案 4 :(得分:0)

解决这个问题:

  1. 打开package.json并将反应版本编辑为:

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

  2. 删除node_modules目录

  3. 使用命令npm install

  4. 重新安装npm
  5. 另外:如果您收到app:compileDebugJava错误,请运行react-native upgrade

  6. (从this github page获得解决方案,它对我有用)

答案 5 :(得分:0)

由于gradle不支持基于每个工件声明存储库。

我修改了build.gradle(不是app / build.gradle)以强制所有依赖项对特定版本做出反应原生:

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
           }
         }
       }
     }
  }

答案 6 :(得分:0)

如果您将react-native-fbsdk从0.5升级到0.6版本并遇到此问题,请在Android Studio中打开您的Android项目(pathToYourApp/android),它会自动为您提供更新依赖项。现在它应该工作正常!

答案 7 :(得分:0)

按照步骤操作

  1. 在项目gradle(Firstly run command docker ps -a then run these two ./byfn.sh down ./byfn.sh up Successfully able to resolved. )中添加Google Maven,

    Project: build.gradle

  2. 使用以下命令删除现有的Gradle allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } }

    cache

  3. 构建干净并运行