繁体   English   中英

在将admob gradle添加到android应用时,依赖冲突发生错误

[英]Dependencies conflict error while adding admob gradle to android app

我想将Google admob添加到我的Android应用程序之一。 但这会在添加Google服务广告和Firebase广告时显示依赖性冲突错误。

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {

    compileSdkVersion 28
    defaultConfig {

        applicationId "package name"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 2
        versionName "2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
    buildTypes {

        release {

            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

    dependencies {

        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation'com.android.support.test.espresso:espressocore:3.0.2'
        implementation 'com.android.volley:volley:1.1.0'
        implementation 'com.android.support:support-v4:28.0.0'
        implementation 'com.android.support:design:28.0.0'
        implementation "org.jetbrains.anko:anko-commons:$anko_version"
        implementation 'com.android.support:cardview-v7:28.0.0'
        implementation 'com.squareup.picasso:picasso:2.71828'
        implementation 'com.facebook.shimmer:shimmer:0.4.0'
        implementation 'com.google.firebase:firebase-core:16.0.7'
        implementation 'com.google.firebase:firebase-messaging:17.3.4'
        implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
        implementation 'com.sasank.roundedhorizontalprogress:roundedhorizontalprogress:1.0.1'
        implementation 'com.google.firebase:firebase-auth:16.2.0'
        implementation 'com.google.android.gms:play-services-auth:16.0.1'
        implementation 'com.tomer:fadingtextview:2.5'
        implementation 'com.google.firebase:firebase-ads:18.0.0'
        implementation 'com.google.android.gms:play-services-ads:18.0.0'
    }
    apply plugin: 'com.google.gms.google-services'

任何帮助都将非常贴切

检查您的项目gradle是否已添加-

dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.2.0'

当您拥有com.google.android.gms:play-services-ads:18.0.0 ,您不必添加admob,其中包括admob。

您尝试两次刊登广告,因此出现错误。


您也可以删除

implementation 'com.google.firebase:firebase-ads:18.0.0'

因为它也是Google Play服务的一部分。

您无需同时使用firebase-ads和play-services-ads。 您只能使用其中之一。 如果您使用的是Firebase -ads,请遵循Firebase广告 指南;如果您打算单独使用Standard,则请遵循Google Admob指南。

您正在使用:

implementation 'com.google.firebase:firebase-ads:18.0.0'
implementation 'com.google.android.gms:play-services-ads:18.0.0'

您可以查看官方发行说明

警告:此版本是主要版本更新和重大更改。 Google Play服务和Firebase的最新更新包括以下更改:

从Android支持库迁移到Jetpack(AndroidX)库。 除非您在应用中进行以下更改,否则库将无法工作:

  • com.android.tools.build:gradle升级到v3.2.1或更高版本。
  • compileSdkVersion升级到28或更高版本。
  • 更新您的应用程序以使用Jetpack(AndroidX) 按照迁移到AndroidX中的说明进行操作。

同样,“ firebase-ads”依赖项仅引入了现有的“ play-services-ads”库。 Firebase SDK是Google Play服务的一部分。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM