If the support library version of the referenced third-party library is lower than (or inconsistent with) the support library version in app build.gradle, the following problems may occur:
all com.android.support libraries must use the exact same version specification(mixing versions can lead to runtime crashes)
As shown in the figure below:
It’s troublesome to change the version of the support library used by the third-party library. If you use a lot of libraries, you have a lot of work. At this time, we can consider forcing all modules to use the same support library version
Add in app build.gradle:
configurations.all{ resolutionStrategy.eachDependency{ DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '26.1.0' } } } }
Among them, 27.1.1 is the version number of the support library you want to use. You can change it to another one as needed. Attach the build.gradle file
apply plugin: 'com.android.library' apply plugin: 'com.jakewharton.butterknife' android { compileSdkVersion 27 defaultConfig { minSdkVersion 21 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } //Force all modules to use the same version of the support library configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '27.1.1' } } } } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') testImplementation 'junit:junit:4.12' api 'com.android.support.test:runner:1.0.2' api 'com.android.support.test.espresso:espresso-core:3.0.2' api 'com.android.support.constraint:constraint-layout:1.1.3' implementation project(':mavo-annotations') //Android Support pack api 'com.android.support:design:27.1.1' api 'com.android.support:appcompat-v7:27.1.1' api 'com.android.support:support-v4:27.1.1' //Font Icons api 'com.joanzapata.iconify:android-iconify-ionicons:2.2.2' api 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2' //fragmentation api 'me.yokeyword:fragmentation:1.3.6' api 'me.yokeyword:fragmentation-swipeback:1.3.6' //Butter Knife api 'com.jakewharton:butterknife:8.8.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' //Network request dependency api 'com.squareup.okio:okio:1.13.0' api 'com.squareup.okhttp3:okhttp:3.8.1' api 'com.squareup.retrofit2:retrofit:2.3.0' api 'com.squareup.retrofit2:converter-scalars:2.3.0' //AVLoadingIndicatorView api 'com.wang.avi:library:2.1.3' //JSON Dependency for Android api 'com.alibaba:fastjson:1.1.57.android' //banner Dependency api 'com.bigkoo:convenientbanner:2.0.5' api 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32@aar' //Log api 'com.orhanobut:logger:2.1.1' //Database Dependencies api 'org.greenrobot:greendao-generator:3.2.2' api 'org.greenrobot:greendao:3.2.2' }