Как использовать правильную версию в зависимостях для сравнения play-services-ads: 17.2.0 - PullRequest
0 голосов
/ 26 марта 2019

Я хочу использовать 'com.google.android.gms:play-services-ads:17.2.0' в своем проекте Android, но когда после синхронизации я обнаружил, что с ним что-то не так.

Мой проект все еще может скомпилироваться, но приложение упадет, и я найду свой 'com.android.support:appcompat-v7:28.0.0' Видит, как не сравнить для 'com.google.android.gms:play-services-ads:17.2.0'.

Я пытаюсь использовать 'com.android.support:appcompat-v7:26.1.0', чтобы исправить это, но все еще не работает.

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:customtabs:26.1.0 less... (Ctrl+F1) 
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).  Issue id: GradleCompatible

Вот мой журнал: https://pastebin.com/vYEcKsMh

Как я могу это исправитьСпасибо.

Вот мой код:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "playground.com.pgapp"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    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:espresso-core:3.0.2'
    compile 'com.android.support:design:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    compile 'com.google.android.gms:play-services-ads:17.2.0'
    implementation 'com.google.firebase:firebase-ads:17.2.0'
}

configurations.all {
    resolutionStrategy.eachDependency {  details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion "28.0.0"
            }
        }
    }
}

Ответы [ 2 ]

0 голосов
/ 26 марта 2019

Добавьте это в конце уровня приложения build.gradle file

configurations.all {
 resolutionStrategy.eachDependency {  details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion "28.0.0"
        }
    }
  }
}

Кредит Евгений Печанец

EDIT: Вы добавили метаданные в манифест

 <meta-data
        android:name="com.google.android.gms.ads.AD_MANAGER_APP"
        android:value="true"/>

и

 <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="YOUR_ADMOB_APP_ID"/>
0 голосов
/ 26 марта 2019

Добавить ниже зависимости

implementation 'com.android.support:customtabs:28.0.0'
...