升级AndroidX

很多人在升级Android Studio之后,发现项目疯狂报错,经过一番搜索,结论是你的项目需要进行AndroidX升级了。

如何对老的项目进行AndroidX升级了,下面是几个步骤:

1、修改gradle.properties

android.useAndroidX=true
android.enableJetifier=true
  • android.useAndroidX=true 表示当前项目启用 androidx
  • android.enableJetifier=true 表示将依赖包也迁移到androidx 。如果取值为false,表示不迁移依赖包到androidx,但在使用依赖包中的内容时可能会出现问题,当然了,如果你的项目中没有使用任何三方依赖,那么,此项可以设置为false

2、Refactor > Migrate to AndroidX

在这里插入图片描述

3、升级为28.0.0以上

apply plugin: 'com.android.application'
apply plugin: 'project-report'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.0'

    defaultConfig {
        applicationId "com.example.mapdemo"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.android.gms:play-services-maps:12.0.1'
    implementation 'com.android.support:support-v4:28.0.0'
    // Needed for the LiteListDemo
    implementation "com.android.support:recyclerview-v7:28.0.0"
}



你有可能会报这个错
Didn't find class "org.apache.http.ProtocolVersion
原因分析

Android P Developer Preview的bug

解决办法

在AndroidManifest.xml文件中标签里面加入

<uses-library android:name="org.apache.http.legacy" android:required="false"/>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值