Androidx for support

Recently, I found a new androidx when I created the project, and the good library I used before can no longer be used. In order to catch up with the project, I changed androidx to the previous support, and the steps are recorded here.

  • Project rootgradle.propertiesIn theandroid.useAndroidXandroid.enableJetifierChange it to false or comment it out
  • compileSdkVersionDon’t use version 29. Mine is
CompileSdkVersion = 28 buildToolsVersion = '28.0.3' minSdkVersion = 21 targetSdkVersion = 28Copy the code
  • replaceapp/build.gradleIntroduction file for andoirdx in.

The original file

apply plugin: 'com.android.application' android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { applicationId "xxx" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode rootProject.ext.versionCode versionName rootProject.ext.versionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release {  minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'}} lintOptions {disable 'GoogleAppIndexingWarning'}} implementation fileTree(dir: 'libs', include: [' *. Jar ']) implementation 'androidx. Appcompat: appcompat: 1.1.0' implementation 'androidx. Constraintlayout: constraintlayout: 1.1.3' testImplementation junit: junit: '4.12' androidTestImplementation 'androidx. Test. Ext: junit: 1.1.1' androidTestImplementation 'androidx. Test. Espresso: espresso - core: 3.2.0'}Copy the code

Replace with

apply plugin: 'com.android.application' android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { applicationId "xxx" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode rootProject.ext.versionCode versionName rootProject.ext.versionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'}} lintOptions {disable 'GoogleAppIndexingWarning'}} implementation fileTree(dir: 'libs', include: [' *. Jar ']) implementation 'com. Android. Support: appcompat - v7:28.0.0' testImplementation junit: junit: '4.12' AndroidTestImplementation 'com. Android. Support. Test: runner: 1.0.2' androidTestImplementation 'com. Android. Support. Test. Espresso: espresso - core: 3.0.2'}Copy the code
  • Then search the keyword AndroidX in the project and replace android with support

  • If it still doesn’t work, use the command to view dependencies.

./gradlew :app:dependencies

Copy the code
  • I noticed here that Glide relies on androidx, so I downgraded the Glide version and replaced it with androidx
Implementation (' com. Making. Bumptech. Glide: glide: 4.7.1 ') annotationProcessor 'com. Making. Bumptech. Glide: the compiler: 4.7.1'Copy the code
  • I finally have it running.