催化剂
我将Android Studio升级到2.3,将Gradle插件升级到3.3
最初的问题
将Gradle插件更新为3.3后,我收到错误"错误:SDK Build Tools修订版(23.0.3)对于项目来说太低了':mymodulename'.最低要求是25.0.0"
我尝试将buildToolsVersion调整为25.0.2并将compileSdkVersion调整为25,以及所有com.android.support依赖项(因为它们的主要版本需要匹配compileSdkVersion).这个调整清除了这个问题,但后来我意识到我的应用程序还不支持Nougat所以我将compileSdkVersion减少到了我的targetSdkVersion 23.关于构建工具太低的错误信息仍然没有了,所以我觉得我很清楚.
第一个依赖错误
将compileSdkVersion击倒到23之后,我试图重建,并看到几个类似于"错误的错误:(3)错误检索项目的父项:找不到与给定名称匹配的资源'android:TextAppearance.Material.Widget.Button.Borderless.有色'".我意识到我忘记改变我的com.android.support依赖项,使得它们的主要版本再次与较低的compileSdkVersion匹配,所以我将它们降低到23.3.0
第二个依赖错误
在解决了第一个依赖性错误后,我能够再次编译并运行我的应用程序.但是,在我的第一个com.android.support依赖项下面仍然存在红色波形,错误说明"所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).发现版本24.0 .0,23.3.0.例子包括com.android.support:support-v4:24.0.0和com.android.support:animated-vector-drawable:23.3.0"
我的build.gradle中没有任何内容专门引用24.0.0,看哪:
apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion '25.0.2' defaultConfig { applicationId ... minSdkVersion 16 targetSdkVersion 23 versionCode ... versionName ... } buildTypes { debug{ debuggable true minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } lintOptions{ //check for errors in release builds, // but continue the build even when errors are found: abortOnError false } dexOptions{ jumboMode true } } repositories { // You can also use jcenter if you prefer mavenCentral() } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' //android support libs etc. compile 'com.android.support:appcompat-v7:23.3.0' compile 'com.android.support:support-v13:23.3.0' compile 'com.android.support:mediarouter-v7:23.3.0' compile 'com.android.support:recyclerview-v7:23.3.0' //snackbar support compile 'com.android.support:design:23.3.0' //Facebook Android SDK compile 'com.facebook.android:facebook-android-sdk:4.7.0' //Facebook Audience Network SDK. Only versions 4.6.0 and above are available compile 'com.facebook.android:audience-network-sdk:4.7.0' //gplay services dependencies compile 'com.google.android.gms:play-services-plus:10.0.1' compile 'com.google.android.gms:play-services-analytics:10.0.1' compile 'com.google.android.gms:play-services-location:10.0.1' //provides Firebase Analytics compile 'com.google.firebase:firebase-core:10.0.1' //provides Google Mobile Ads SDK, a.k.a the AdMob service. compile 'com.google.firebase:firebase-ads:10.0.1' //dependencies required by the InMobi ads SDK compile 'com.squareup.picasso:picasso:2.5.2' } apply plugin: 'com.google.gms.google-services'
依赖树
为了弄清楚24.0.0依赖的来源,我使用'./gradlew -q dependencies mymodulename:dependencies --configuration compile'创建了一个依赖树.输出是:
compile - Classpath for compiling the main sources. +--- com.android.support:appcompat-v7:23.3.0 | +--- com.android.support:support-vector-drawable:23.3.0 | | \--- com.android.support:support-v4:23.3.0 -> 24.0.0 | | \--- com.android.support:support-annotations:24.0.0 | +--- com.android.support:animated-vector-drawable:23.3.0 | | \--- com.android.support:support-vector-drawable:23.3.0 (*) | \--- com.android.support:support-v4:23.3.0 -> 24.0.0 (*) +--- com.android.support:support-v13:23.3.0 | \--- com.android.support:support-v4:23.3.0 -> 24.0.0 (*) +--- com.android.support:mediarouter-v7:23.3.0 | +--- com.android.support:appcompat-v7:23.3.0 (*) | \--- com.android.support:palette-v7:23.3.0 | \--- com.android.support:support-v4:23.3.0 -> 24.0.0 (*) +--- com.android.support:design:23.3.0 | +--- com.android.support:appcompat-v7:23.3.0 (*) | +--- com.android.support:support-v4:23.3.0 -> 24.0.0 (*) | \--- com.android.support:recyclerview-v7:23.3.0 | +--- com.android.support:support-v4:23.3.0 -> 24.0.0 (*) | \--- com.android.support:support-annotations:23.3.0 -> 24.0.0 +--- com.facebook.android:facebook-android-sdk:4.7.0 | +--- com.parse.bolts:bolts-android:1.2.0 | \--- com.android.support:support-v4:[22,23) -> 24.0.0 (*) +--- com.facebook.android:audience-network-sdk:4.7.0 | \--- com.google.android.gms:play-services-ads:7.8.0 -> 10.0.1 | +--- com.google.android.gms:play-services-ads-lite:10.0.1 | | \--- com.google.android.gms:play-services-basement:10.0.1 | | \--- com.android.support:support-v4:24.0.0 (*) | +--- com.google.android.gms:play-services-base:10.0.1 | | +--- com.google.android.gms:play-services-basement:10.0.1 (*) | | \--- com.google.android.gms:play-services-tasks:10.0.1 | | \--- com.google.android.gms:play-services-basement:10.0.1 (*) | +--- com.google.android.gms:play-services-clearcut:10.0.1 | | +--- com.google.android.gms:play-services-base:10.0.1 (*) | | \--- com.google.android.gms:play-services-basement:10.0.1 (*) | +--- com.google.android.gms:play-services-basement:10.0.1 (*) | \--- com.google.android.gms:play-services-gass:10.0.1 | \--- com.google.android.gms:play-services-basement:10.0.1 (*) +--- com.google.android.gms:play-services-plus:10.0.1 | +--- com.google.android.gms:play-services-base:10.0.1 (*) | \--- com.google.android.gms:play-services-basement:10.0.1 (*) +--- com.google.android.gms:play-services-analytics:10.0.1 | +--- com.google.android.gms:play-services-analytics-impl:10.0.1 | | +--- com.google.android.gms:play-services-base:10.0.1 (*) | | \--- com.google.android.gms:play-services-basement:10.0.1 (*) | +--- com.google.android.gms:play-services-base:10.0.1 (*) | +--- com.google.android.gms:play-services-basement:10.0.1 (*) | \--- com.google.android.gms:play-services-tagmanager-v4-impl:10.0.1 | +--- com.google.android.gms:play-services-analytics-impl:10.0.1 (*) | +--- com.google.android.gms:play-services-base:10.0.1 (*) | \--- com.google.android.gms:play-services-basement:10.0.1 (*) +--- com.google.android.gms:play-services-location:10.0.1 | +--- com.google.android.gms:play-services-base:10.0.1 (*) | +--- com.google.android.gms:play-services-basement:10.0.1 (*) | \--- com.google.android.gms:play-services-tasks:10.0.1 (*) +--- com.google.firebase:firebase-core:10.0.1 | \--- com.google.firebase:firebase-analytics:10.0.1 | +--- com.google.android.gms:play-services-basement:10.0.1 (*) | +--- com.google.firebase:firebase-common:10.0.1 | | +--- com.google.android.gms:play-services-basement:10.0.1 (*) | | \--- com.google.android.gms:play-services-tasks:10.0.1 (*) | \--- com.google.firebase:firebase-analytics-impl:10.0.1 | +--- com.google.android.gms:play-services-basement:10.0.1 (*) | +--- com.google.firebase:firebase-iid:10.0.1 | | +--- com.google.android.gms:play-services-basement:10.0.1 (*) | | \--- com.google.firebase:firebase-common:10.0.1 (*) | \--- com.google.firebase:firebase-common:10.0.1 (*) +--- com.google.firebase:firebase-ads:10.0.1 | +--- com.google.android.gms:play-services-ads:10.0.1 (*) | \--- com.google.firebase:firebase-analytics:10.0.1 (*) +--- com.squareup.picasso:picasso:2.5.2 \--- com.android.support:recyclerview-v7:23.3.0 (*) (*) - dependencies omitted (listed previously)
问题
依赖树语法'lib version - >不同的lib版'是什么意思?具体来说,当树说"com.android.support:support-v4:23.3.0 - > 24.0.0"时,它是什么意思?
如果我的其他一些依赖项中有com.android.support版本24.xx库的隐式要求(请参阅com.google.android.gms:play-services-basement:10.0.1,具体取决于com.android.support:support -v4:24.0.0),为什么在之前提到的Android Studio,Gradle插件和buildToolsVersion更新之前没有这个build.gradle抛出错误?
如何确保所有依赖项与compileSdkVersion 23兼容?
Gabriele Mar.. 6
具体来说,当树说"com.android.support:support-v4:23.3.0 - > 24.0.0"时,它是什么意思?
这意味着库具有com.android.support:support-v4:23.3.0
嵌套的相关性,但在这种情况下,您只是使用相同依赖项的另一个更高版本com.android.support:support-v4:24.0.0
.
换句话说项目中使用的com.android.support:support-v4:24.0.0
为什么在之前提到的Android Studio,Gradle插件和buildToolsVersion更新之前没有这个build.gradle抛出错误?
因为您已将Gradle插件更新为具有此类检查的3.3.
如何确保所有依赖项与compileSdkVersion 23兼容?
这很难.
唯一的方法是检查所有依赖项,但我建议您使用:
compileSdkVersion 25 targetSdkVersion 23
通常,buildToolsVersion
在任何情况下都使用最新版本是一个好主意,独立于所使用的支持库的版本.
此外.强烈建议您始终使用最新的SDK进行编译.这意味着今天你应该使用compileSdkVersion
25.
具体来说,当树说"com.android.support:support-v4:23.3.0 - > 24.0.0"时,它是什么意思?
这意味着库具有com.android.support:support-v4:23.3.0
嵌套的相关性,但在这种情况下,您只是使用相同依赖项的另一个更高版本com.android.support:support-v4:24.0.0
.
换句话说项目中使用的com.android.support:support-v4:24.0.0
为什么在之前提到的Android Studio,Gradle插件和buildToolsVersion更新之前没有这个build.gradle抛出错误?
因为您已将Gradle插件更新为具有此类检查的3.3.
如何确保所有依赖项与compileSdkVersion 23兼容?
这很难.
唯一的方法是检查所有依赖项,但我建议您使用:
compileSdkVersion 25 targetSdkVersion 23
通常,buildToolsVersion
在任何情况下都使用最新版本是一个好主意,独立于所使用的支持库的版本.
此外.强烈建议您始终使用最新的SDK进行编译.这意味着今天你应该使用compileSdkVersion
25.