我正在使用 Google ADS SDK 构建一个应用程序,一切都很正常,直到今天接到通知更新 Android Studio。随着更新,我也被提示将 Gradle 更新到 4.4 版本,并将所有支持库版本更新为 27.1.0。
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
然后我遇到了Gradle错误,显示“Android依赖'com.android.support:support-v4'在编译(26.1.0)和运行时(27.1.0)类路径中具有不同版本。您应该通过DependencyResolution手动设置相同的版本。”
我搜索了我的代码,没有一个单词可以匹配“26.1.0”。我也尝试删除所有的build/gradle缓存,但仍然无法解决这个问题。所以我使用“gradlew.bat -q dependencies”来发现似乎ADS库有错误的依赖。
这两行非常可疑:
+--- com.android.support:support-v4:26.1.0
+--- com.android.support:support-media-compat:26.1.0
与其他依赖项设置相比较
+--- project :MyAdsProject
+--- com.android.support:appcompat-v7:27.1.0
| +--- com.android.support:support-annotations:27.1.0
| +--- com.android.support:support-core-utils:27.1.0
| | +--- com.android.support:support-annotations:27.1.0
| | \--- com.android.support:support-compat:27.1.0
| | +--- com.android.support:support-annotations:27.1.0
| | \--- android.arch.lifecycle:runtime:1.1.0
| | +--- android.arch.lifecycle:common:1.1.0
| | \--- android.arch.core:common:1.1.0
| +--- com.android.support:support-fragment:27.1.0
| | +--- com.android.support:support-compat:27.1.0 (*)
| | +--- com.android.support:support-core-ui:27.1.0
| | | +--- com.android.support:support-annotations:27.1.0
| | | +--- com.android.support:support-compat:27.1.0 (*)
| | | \--- com.android.support:support-core-utils:27.1.0 (*)
| | +--- com.android.support:support-core-utils:27.1.0 (*)
| | +--- com.android.support:support-annotations:27.1.0
| | +--- android.arch.lifecycle:livedata-core:1.1.0
| | | +--- android.arch.lifecycle:common:1.1.0
| | | +--- android.arch.core:common:1.1.0
| | | \--- android.arch.core:runtime:1.1.0
| | | \--- android.arch.core:common:1.1.0
| | \--- android.arch.lifecycle:viewmodel:1.1.0
| +--- com.android.support:support-vector-drawable:27.1.0
| | +--- com.android.support:support-annotations:27.1.0
| | \--- com.android.support:support-compat:27.1.0 (*)
| \--- com.android.support:animated-vector-drawable:27.1.0
| +--- com.android.support:support-vector-drawable:27.1.0 (*)
| \--- com.android.support:support-core-ui:27.1.0 (*)
\--- com.google.android.gms:play-services-ads:12.0.1
+--- com.google.android.gms:play-services-ads-lite:12.0.1
| +--- com.google.android.gms:play-services-basement:12.0.1
| | +--- com.android.support:support-v4:26.1.0
| | | +--- com.android.support:support-compat:26.1.0 -> 27.1.0 (*)
| | | +--- com.android.support:support-media-compat:26.1.0
| | | | +--- com.android.support:support-annotations:26.1.0 -> 27.1.0
| | | | \--- com.android.support:support-compat:26.1.0 -> 27.1.0 (*)
| | | +--- com.android.support:support-core-utils:26.1.0 -> 27.1.0 (*)
| | | +--- com.android.support:support-core-ui:26.1.0 -> 27.1.0 (*)
| | | \--- com.android.support:support-fragment:26.1.0 -> 27.1.0 (*)
| | \--- com.google.android.gms:play-services-basement-license:12.0.1
| \--- com.google.android.gms:play-services-ads-lite-license:12.0.1
+--- com.google.android.gms:play-services-basement:12.0.1 (*)
+--- com.google.android.gms:play-services-gass:12.0.1
| +--- com.google.android.gms:play-services-basement:12.0.1 (*)
| \--- com.google.android.gms:play-services-gass-license:12.0.1
\--- com.google.android.gms:play-services-ads-license:12.0.1
有人知道如何摆脱这个问题吗?ADS 12.0.1已经是最新版本了。