android - 'com.google.android.gms :play-services-base' has different for the compile (15. 0.1) 和运行时 (16.0.1)

标签 android react-native gradle react-native-maps

我在构建应用程序时遇到以下错误

Android dependency 'com.google.android.gms:play-services-base' has different version for the compile (15.0.1) and runtime (16.0.1) classpath. You should manually set the same version via DependencyResolution

APP/build.gradle 文件

    apply plugin: "com.android.application"

import com.android.build.OutputFile


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

apply from: "../../node_modules/react-native/react.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 26
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.afbmobilebanking"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 14
        versionName "1.0.9"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        multiDexEnabled true
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    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
            }
        }
    }
    buildTypes {
        release {
            debuggable false
            // minifyEnabled true
            // shrinkResources true
            signingConfig signingConfigs.release
            //  minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    lintOptions {
        abortOnError false
    }
    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"
//        }
//    }
    // 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
            }
        }
    }
}

dependencies {
    implementation project(':react-native-maps')
    implementation project(':react-native-i18n')
    implementation project(':react-native-device-info')
    implementation project(':react-native-maps')
    implementation project(':react-native-device-info')
    implementation project(':react-native-i18n')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:23.0.1"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.facebook.fresco:animated-gif:1.3.0'
//    implementation(project(':react-native-maps')) {
//        exclude group: 'com.google.android.gms', module: 'play-services-base'
//        exclude group: 'com.google.android.gms', module: 'play-services-maps'
//    }
    implementation 'com.google.android.gms:play-services-base:15.0.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

请告诉我如何解决此问题。

最佳答案

您的某些库可能依赖于播放服务。您可以使用以下命令查看依赖关系树:

$ ./gradlew app:dependencies

然后您可以从库中排除冲突的依赖项或尝试将所有库升级到最新版本, 或者尝试使用简单地忽略问题(不推荐)

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

关于android - 'com.google.android.gms :play-services-base' has different for the compile (15. 0.1) 和运行时 (16.0.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52753817/

相关文章:

java - 我可以用一个全新的项目覆盖 Git 存储库吗?

java - 使用 gradle 显示第一个 OSGi 构建 - 从 ant 迁移到 Gradle

react-native - 无法捕获由redux-saga call()引发另一个错误的错误

node.js - Node 服务器卡在加载依赖图上

Android:在不耗尽电池的情况下使用 AlarmManager 的正确方法

android.widget.TextView 无法转换为 android.view.ViewGroup

javascript - React-Navigation - 标题与其屏幕组件的交互,失败的 Prop 类型

gradle - 在Gradle中设置环境变量

android - 无法访问 DynamoDB 表

java - 主要 Activity 在启动屏幕返回之前被破坏