【问题标题】:react-native run-android build failed Could not find com.google.android.gms:play-services-measurement-api:9.8.0react-native run-android build failed 找不到 com.google.android.gms:play-services-measurement-api:9.8.0
【发布时间】:2018-10-07 17:54:06
【问题描述】:

在将 React-native-firebase 添加到应用程序后尝试构建我的 react native 项目会导致它无法构建应用程序。我收到以下错误:

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.google.android.gms:play-services-measurement-api:9.8.0.
  Searched in the following locations:
      file:/Users/cliffc/Library/Android/sdk/extras/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/Library/Android/sdk/extras/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      file:/Users/cliffc/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      file:/Users/cliffc/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      file:/Users/cliffc/.m2/repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/.m2/repository/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://jcenter.bintray.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      file:/Users/cliffc/projects/prod/commconn/cc/node_modules/react-native/android/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      file:/Users/cliffc/projects/prod/commconn/cc/node_modules/react-native/android/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://maven.google.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://maven.google.com/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
      https://jitpack.io/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.pom
      https://jitpack.io/com/google/android/gms/play-services-measurement-api/9.8.0/play-services-measurement-api-9.8.0.aar
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.3 > com.google.firebase:firebase-measurement-connector-impl:17.0.1
      project :app > com.google.android.gms:play-services:9.8.0 > com.google.firebase:firebase-analytics:16.0.3

这只是其中之一 我在以下服务中遇到相同的错误:

Could not find com.google.android.gms:play-services-measurement-base:9.8.0.
Could not find com.google.android.gms:play-services-stats:9.8.0.
Could not find com.google.android.gms:play-services-ads-identifier:9.8.0.

我的 MainApplication 获取包是:

protected List<ReactPackage> getPackages() {
    // Add additional packages you require here
    // No need to add RnnPackage and MainReactPackage
    mCallbackManager = new CallbackManager.Factory().create();
    return Arrays.<ReactPackage>asList(new MapsPackage(), new RNDeviceInfo(), new FBSDKPackage(mCallbackManager),
        new PickerPackage(), new RNFetchBlobPackage(), new VectorIconsPackage(),
        new ReactNativePushNotificationPackage(), new RNFirebasePackage());
    // eg. new VectorIconsPackage()
  }

Build.gradle(应用程序):

ext {
    compileSdkVersion   = 27
    targetSdkVersion    = 27
    buildToolsVersion   = "27.0.1"
    supportLibVersion   = "26.1.0"
    googlePlayServicesVersion = "15.0.1"
    androidMapsUtilsVersion = "0.5+"
    firebaseVersion = "+"
}

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.1"

    defaultConfig {
        applicationId "com.commonconnectapp"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 22
        versionName "1.0.1"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                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 are e.g. debug, 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
            }
        }
    }
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            details.useVersion('9.8.0')
        }
    }
}

dependencies {
    compile project(':react-native-firebase')
   compile project(':react-native-push-notification')
    compile project(':react-native-maps')
    compile project(':react-native-image-picker')
    compile project(':react-native-fbsdk')
    compile project(':rn-fetch-blob')
    compile project(':react-native-vector-icons')
    compile project(':react-native-image-crop-picker')
    compile project(':react-native-device-info')
    compile fileTree(dir: "libs", include: ["*.jar"])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:multidex:1.0.3'
    // compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    implementation project(':react-native-maps')
    compile project(':react-native-navigation')
    implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-firebase')
    implementation "com.google.firebase:firebase-core:16.0.3"
    compile "com.google.android.gms:play-services:15.0.1"
}

在此先感谢您的帮助。如果需要更多信息,请告诉我。我一直在寻找并尝试了一些修复无济于事。如果我找到它,我会继续研究并自己添加答案。

【问题讨论】:

    标签: javascript android react-native react-native-android react-native-firebase


    【解决方案1】:

    类似的事情以前发生在我身上。当你安装这样的原生依赖项时,在 android studio 中你会看到除了你的主要 react native 应用程序之外的不同项目。

    如果您正确安装,其中一个项目应该是对本机 firebase 的反应。 嗯,thia 项目,和你的主应用项目一样,也有一个带有依赖关系的 gradle 文件。

    检查错误指定的库是否存在,是否与主应用程序中的 gms 服务版本相同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-11
      • 1970-01-01
      • 2016-10-09
      • 2019-01-11
      • 1970-01-01
      相关资源
      最近更新 更多