我正在使用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”。我也尝试删除所有的构建/渐变缓存,但仍然无法摆脱这个问题。因此,我使用 gradlew.bat -q依赖性来发现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已经是当前最新版本。
最佳答案
在您的应用程序级别build.gradle
中:
android {
configurations.all {
resolutionStrategy.force 'com.android.support:support-v4:27.1.1'
}
}
这将告诉您的gradle配置在导入的所有地方强制选择和应用
support-v4:27.1.1
!希望这可以帮助!