Android依赖项“ com.google.firebase:firebase-iid”对于编译(16.0.0)和运行时(18.0.0)类路径具有不同的版本

时间:2019-05-14 10:52:05

标签: react-native react-native-android

在我的本机应用程序中,我正在集成react-native-push-notification并得到此错误。

app / build.gradle

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"

    defaultConfig {
        applicationId "xxxxxxx"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    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-push-notification')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:23.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

// 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'
}
apply plugin: 'com.google.gms.google-services'

项目build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:4.0.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        google()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.0.2"
            }
        }
    }
}

我尝试了各种解决方案,例如在configuration.all中添加了检查以获取特定版本的firebase-core的方法,例如从“ implementaion”更改为“ api”,但是没有任何效果。

反应本机版本为0.55.4

2 个答案:

答案 0 :(得分:0)

react-native-push-notification的{​​{1}}中的com.google.firebase:firebase-messaging的依赖项声明为'+'。这将从maven repo获取该库的最新版本。

这与build.gradle文件android/app/build.gradle中的版本声明冲突。

将此添加到您的项目级别16.0.1

build.gradle

答案 1 :(得分:0)

我找到了解决方案。 在我项目的build.gradle buildscript-> dependencies中,我将google-services gradle插件的版本从“ 4.0.2”替换为“ 4.2.0”,并且有效。

classpath'com.google.gms:google-services:4.2.0'