How to use Gradle dependency tree to resolve version mismatch of Android support library?

catalyst

I upgraded Android Studio to version 2.3 and Gradle to 3.3

initial problem

After updating the Gradle plugin to 3.3, I received the error "Error: SDK Build Tools version (23.0.3) is too small for the project: mymodulename". The minimum value is 25.0.0 "

I tried to set both buildToolsVersion to 25.0.2, and compileSdkVersion to 25, as well as all com.android.support dependencies (since their main version should match compileSdkVersion). This setup cleared this problem, but then I realized that my application does not support Nougat, but I reduced compileSdkVersion to my targetSdkVersion 23. The error message was too small due to a build error, so I thought I was clear.

first dependency error

After detonating compileSdkVersion to 23, I tried to rebuild and saw several errors like "Error: (3) Error getting the parent element for the element: the resource was not found that matches the specified name" android: TextAppearance.Material.Widget.Button.Borderless.Colored " I realized that I forgot to change my com.android.support dependencies so that their main version again corresponded to the lower compileSdkVersion command, so I scribbled them until 23.3.0

second dependency error

After resolving the first dependency error, I was able to compile and run the application again. However, compared to my first dependency on com.android.support, there was still a red error, with a note about the error "all com.android.support libraries should use the same version specification (mixing versions may cause crashes at runtime) .. 0, 23.3.0. Examples include com.android.support:support-v4:24.0.0 and com.android.support:animated-vector-drawable:23.3.0 "

Nothing in my build.gradle refers to 24.0.0, here:

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, aka 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' 

dependency tree

To find out where the 24.0.0 dependency came from, I created a dependency tree using "./gradlew -q dependencies mymodulename: dependencies --configuration compile". Output:

  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) 

the questions

  • What does the syntax of the dependency tree 'lib version → different lib version' mean? In particular, when the tree says "com.android.support:support-v4:23.3.0 → 24.0.0", what does this mean?

  • If there are implicit library requirements for com.android.support version 24.xx in some of my other dependencies (see com.google.android.gms: play-services-basement: 10.0.1 depending on com.android.support: support -v4: 24.0.0), why this build.gradle error was not removed before updating Android Studio, Gradle and buildToolsVersion mentioned earlier?

  • How can I make sure all my dependencies are compatible with compileSdkVersion 23?

+5
source share
1 answer

In particular, when the tree says "com.android.support:support-v4:23.3.0 → 24.0.0", what does this mean?

This means the library has com.android.support:support-v4:23.3.0 as a nested difference, but you just use a different and higher version of the same dependencies, in this case com.android.support:support-v4:24.0.0 .
In other words, your project uses com.android.support:support-v4:24.0.0

why this build.gradle error was not removed before installing Android Studio, the Gradle plugin and buildToolsVersion mentioned earlier?

Since you upgraded the Gradle plugin to version 3.3, which has such a check.

How can I make sure all my dependencies are compatible with compileSdkVersion 23?

It is rather complicated. The only way is to check all the dependencies, but I suggest you use:

 compileSdkVersion 25 targetSdkVersion 23 

In general, it is recommended that you use the latest version of buildToolsVersion in any case, regardless of the version of supported libraries used.

Moreover. It is highly recommended that you always compile with the latest SDK . That means you should use compileSdkVersion 25 today.

+6
source

Source: https://habr.com/ru/post/1265211/


All Articles