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/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章