![](/img/trans.png)
[英]build.gradle file error in Android Studio can't applied main & dependencies
[英]Mixing android dependency versions error message in build.gradle file, however can't find the dependencies that are different
我在build.gradle文件中收到以下錯誤消息:
所有com.android.support庫都必須使用完全相同的版本規范(混合版本可能導致運行時崩潰)。 找到版本28.0.0、25.2.0。 示例包括com.android.support:animated-vector-drawable:28.0.0和com.android.support:support-media-compat:25.2.0 less ...(Ctrl + F1)有一些庫組合,或者不兼容或可能導致錯誤的工具和庫。 一種不兼容的情況是使用不是最新版本的Android支持庫版本進行編譯(或者特別是低於目標targetSdkVersion的版本)。
以下是我的build.gradle文件的當前狀態。 但是,我看不到任何對上述錯誤消息中提到的不同版本的依存關系的明確引用。
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.parse.ideanetwork"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 5
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:28'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:28.0.0'
compile 'com.google.android.gms:play-services-ads:11.0.0'
compile "com.github.parse-community.Parse-SDK-Android:parse:1.18.5"
}
任何幫助深表感謝。 謝謝。
明確聲明最舊的版本與最新版本的依賴似乎有效。 我認為這不是更好的解決方案(也許根本不是孤注一擲),但是它消除了警告。 這就是我正在做的事情,直到現在一切都沒有中斷。
使用此功能,可以解決依賴版本不兼容的問題。
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
// Skip multidex because it follows a different versioning pattern.
if (!requested.name.startsWith("multidex")) {
details.useVersion '28.0.0'
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.