图书馆[[15.0.4],[16.0.2]]正在申请com.google.android.gms:play-services-measurement-base库,但已解析为16.0.2

问题描述 投票:0回答:2

我搜索了一个解决方案,并在stackoverflow(如solution 1)上看到了此错误的其他答案。

这是我的build.gradle

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    signingConfigs {
    }
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    useLibrary 'org.apache.http.legacy'

    buildTypes {
        ...
    }

}

dependencies {
implementation files('libs/jsoup-1.8.1.jar')
implementation files('libs/org.apache.http.legacy.jar')
implementation files('libs/opencsv-3.8.jar')

implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-messaging:17.3.2'

implementation 'com.firebaseui:firebase-ui-database:3.2.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-auth:16.0.0'

implementation "com.android.support:design:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'

implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
    transitive = true
}
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.installreferrer:installreferrer:1.0'

}

apply plugin: 'com.google.gms.google-services'

但每次我尝试编译我都会得到错误:

图书馆com.google.android.gms:play-services-measurement-base正在[[15.0.4,15.0.4],[16.0.2,16.0.2]]的各种其他图书馆提出要求,但已解决为16.0.2。禁用插件并使用./gradlew:app:dependencies检查依赖关系树。

这是我的顶级build.gradle:

buildscript {
repositories {
    jcenter()
    maven {
        url 'https://maven.fabric.io/public'
    }

    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.4'
    classpath 'com.google.gms:google-services:4.0.1'
    classpath 'io.fabric.tools:gradle:1.24.4'

   }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven {
            url "https://maven.google.com"
        }

    }
}

我刚刚更新了所有依赖项到最新版本,我不知道如何构建我的项目。

谢谢!

android android-studio android-gradle build.gradle
2个回答
0
投票

我只是想通了依赖它命令它很重要......现在我把它放了

implementation 'com.google.firebase:firebase-core:16.0.3'

在顶部,我没有任何构建问题!

这是我的构建gradle:

dependencies {
implementation files('libs/jsoup-1.8.1.jar')
implementation files('libs/org.apache.http.legacy.jar')
implementation files('libs/opencsv-3.8.jar')

implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.2'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-config:16.0.0'

implementation 'com.google.firebase:firebase-messaging:17.3.2'

implementation 'com.firebaseui:firebase-ui-database:3.2.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-auth:16.0.0'

implementation "com.android.support:design:27.1.1"
implementation "com.android.support:customtabs:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'

implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
    transitive = true
}
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.installreferrer:installreferrer:1.0'


}

0
投票

为解决此问题,我遵循了Google firebase集成指南,并在app / build.gradle和project / build.gradle中进行了以下更改

如果您有任何疑问,请点击此链接

https://firebase.google.com/docs/android/setup

app / build.gradle中的更改

    implementation (project(':react-native-firebase')) {
        transitive = false
     }
    implementation 'com.google.android.gms:play-services-base:15.0.2'
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.firebase:firebase-messaging:17.4.0"

project / build.gradle中的更改

repositories {

        google()
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

//Below line of code should be latest if you are using firebase version 16.0 +

        classpath 'com.google.gms:google-services:4.2.0'// below google-services plugin
       
    }
    allprojects {
    repositories {
         google()// add it to top instead of bottom or somewhere in middle
        mavenLocal()
        mavenCentral()
        maven {
            url 'https://maven.google.com'
        }
       
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.