androidx 换成 support

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'

我这终于可以运行了。
————————————————
版权声明:本文为CSDN博主「Android唐浮」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011368551/article/details/103222807/

你可能感兴趣的:(Java,Android开发)