更新到android studio 2.3后,我收到了这个错误消息。我知道这只是一个提示,因为应用程序运行正常,但这真的很奇怪。
所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本25.1.1、24.0.0。示例包括com.android.support:animatedvector-drawable:25.1.1和com.android.com/support:mediarouter-v7:24.0.0
我的成绩:
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'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.blankj:utilcode:1.3.6'
compile 'com.orhanobut:logger:1.15'
compile 'com.facebook.stetho:stetho:1.4.2'
provided 'com.google.auto.value:auto-value:1.2'
annotationProcessor 'com.google.auto.value:auto-value:1.2'
annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'
compile 'com.mikepenz:iconics-core:2.8.2@aar'
compile('com.mikepenz:materialdrawer:5.8.1@aar') { transitive = true }
compile 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
compile 'com.github.GrenderG:Toasty:1.1.1'
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.8.0'
compile 'com.github.MAXDeliveryNG:slideview:1.0.0'
compile 'com.facebook.fresco:fresco:1.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.maps.android:android-maps-utils:0.4.4'
compile 'com.github.jd-alexander:library:1.1.0'
}
解决这个问题的最佳方法是实现AndroidStudio建议的所有“com.android.support:…”
(无论您使用的是哪种支持版本–27.1.1、28.0.0等)
将光标放在错误行,例如。
implementation 'com.android.support:appcompat-v7:28.0.0'
Android Studio将向您建议“com.Android.support:…”是不同于'com.android.support:appcompat-v7:28.0.0'
实例
所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本28.0.0、27.1.0和27.0.2。示例包括com.android.support:animatedvector-drawable:28.0.0和com.android.com/support:exifinterface:27.1.0
所以添加com.android.support:animatedvector-drawable:28.0.0&com.android.support:exifinterface:28.0.0。现在同步渐变文件。
一个接一个地尝试实现所有建议的“com.android.support:…”,直到此行实现“com.andrio.support:appcompat-v7:28.0.0”中没有错误
就我而言,我补充道
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
所有这些依赖关系,对你来说可能会有所不同。
我有这个:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.google.firebase:firebase-firestore:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation'com.facebook.android:facebook-login:[4,5)'
implementation 'com.twitter.sdk.android:twitter:3.1.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation project(':vehiclesapi')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
并得到以下错误:
解决方案很简单-主要依赖项都是正确的,因此留下了任何第三方依赖项。一个接一个地删除,直到找到罪魁祸首,结果是facebook!它使用的是27.0.2版本的android支持库。我试图添加cardview 27.1.1版本,但这并不奏效,因为解决方案仍然足够简单。
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-auth:12.0.1'
implementation 'com.google.firebase:firebase-firestore:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation('com.facebook.android:facebook-login:[4,5)'){
// contains com.android.support:v7:27.0.2, included required com.android.support.*:27.1.1 modules
exclude group: 'com.android.support'
}
implementation 'com.android.support:cardview-v7:27.1.1' // to replace facebook sdk's cardview-v7:27.0.2.
implementation 'com.twitter.sdk.android:twitter:3.1.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation project(':vehiclesapi')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}