如何将我的Android项目迁移到Androidx? [英] How can I migrate my Android project to Androidx?

查看:138
本文介绍了如何将我的Android项目迁移到Androidx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将当前的android项目迁移到androidx,因为必须更改不推荐使用的代码.

I have to migrate my current android project to androidx, because I have to change a deprecated code.

我想将'androidx.core:core:1.0.1'添加到项目依赖项中,但由于它与我当前的依赖项不兼容而无法正常工作.

I want to add 'androidx.core:core:1.0.1' to the project dependencies but it doesn't work because it is not compatible with my current dependencies.

有人可以帮助我解决这个问题吗?

Can anyone help me with this issue?

谢谢!

我的build.gradle现在是:

My build.gradle now is:

    implementation 'commons-codec:commons-codec:1.5'
    implementation 'commons-codec:commons-codec:1.10'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:gridlayout-v7:26.1.0'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.gms:play-services-location:10.2.0'
    implementation 'com.google.android.gms:play-services-maps:10.2.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.volley:volley:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'org.jsoup:jsoup:1.10.1'
    implementation 'com.google.android.libraries.places:places:1.1.0'

推荐答案

在Android Studio 3.2及更高版本中,您可以通过从菜单栏中选择重构">迁移到AndroidX",快速迁移现有项目以使用AndroidX.

With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

如果您有尚未迁移到AndroidX命名空间的任何Maven依赖项,则在gradle.properties文件中将以下两个标志设置为true时,Android Studio构建系统也会为您迁移这些依赖项:

If you have any Maven dependencies that have not been migrated to the AndroidX namespace, the Android Studio build system also migrates those dependencies for you when you set the following two flags to true in your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

要迁移不使用具有需要转换的依赖关系的任何第三方库的现有项目,可以将android.useAndroidX标志设置为true,将 android.enableJetifier 标志设置为false.

To migrate an existing project that does not use any third-party libraries with dependencies that need converting, you can set the android.useAndroidX flag to true and the android.enableJetifier flag to false.

这篇关于如何将我的Android项目迁移到Androidx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆