首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >react-native run-android构建失败,找不到com.google.android.gms:play-services-measurement-api:9.8.0

react-native run-android构建失败,找不到com.google.android.gms:play-services-measurement-api:9.8.0
EN

Stack Overflow用户
提问于 2018-10-08 01:54:06
回答 1查看 282关注 0票数 0

在将React- native -firebase添加到应用程序之后,尝试构建我的react本机项目会导致构建应用程序失败。我收到以下错误:

代码语言:javascript
代码运行次数:0
运行
复制
* 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

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

代码语言:javascript
代码运行次数:0
运行
复制
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 get包是:

代码语言:javascript
代码运行次数:0
运行
复制
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 (应用程序):

代码语言:javascript
代码运行次数:0
运行
复制
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"
}

感谢您的帮助。如果需要更多的信息,请让我知道。我一直在搜索并尝试了一些修复方法,但都无济于事。我会继续研究,如果我找到答案,我会自己添加。

EN

回答 1

Stack Overflow用户

发布于 2018-10-08 14:02:08

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

如果安装正确,其中一个项目应该是react native firebase。和你的主应用程序项目一样,这个项目也有一个带有依赖项的gradle文件。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52691274

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档