androidx 换成 support
最近创建项目发现多了个
androidx
,并且以前用的好好的库也不能用了,这里为了赶项目就把androidx
还是换成了之前的support
,这里记录下步骤。
- 项目根目录
gradle.properties
中android.useAndroidX
和android.enableJetifier
改为 false 或者 注释掉 compileSdkVersion
版本不要使用29的,我的是
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
minSdkVersion = 21
targetSdkVersion = 28
- 替换
app/build.gradle
中的有关andoirdx的引入文件。
原文件
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'
}
}
//去manifest除警告
lintOptions {
disable 'GoogleAppIndexingWarning'
}
}
dependencies {
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'
}
替换为
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'
}
}
//去manifest除警告
lintOptions {
disable 'GoogleAppIndexingWarning'
}
}
dependencies {
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'
}
-
然后项目中搜索
androidx
关键字,将android
都换成support
-
如果仍然运行不了,就使用命令查看依赖。
./gradlew :app:dependencies
- 我这里发现Glide依赖了androidx,然后我就把glide版本降低了,换成了
implementation('com.github.bumptech.glide:glide:4.7.1')
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
- 我这终于可以运行了。