有没有一种方法可以将AndroidX和使用支持库的子项目混合使用? [英] Is there a way to mix AndroidX and a subproject that uses the support library?

查看:90
本文介绍了有没有一种方法可以将AndroidX和使用支持库的子项目混合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android项目,我想升级到 AndroidX .但是,我正在使用一个模块,该模块在尚未迁移到AndroidX的其他应用程序之间共享.我想避免分叉代码,而是在将项目的重置升级为使用AndroidX时更喜欢使用模块的支持库.

I have an Android project that I would like to upgrade to AndroidX. However, I am using a module which is shared across other applications that have not migrated to AndroidX yet. I would like to avoid forking the code and prefer using the support library for the module while upgrading the reset of the project to use AndroidX.

现在我无法导入任何 android.support.v7 类.因此,例如 import android.support.v7.widget.AppCompatEditText; 失败.

Right now I cannot import any android.support.v7 classes. So for example import android.support.v7.widget.AppCompatEditText; fails.

我试图恢复模块中迁移工具对 build.gradle 所做的更改,但这不能防止编译问题.

I've tried to revert the changes made to build.gradle by the migration tool in the module but that doesn't prevent the compilation problem.

但是在我的 gradle.properties 中仍然具有:

However in my gradle.properties still has:

android.useAndroidX=true
android.enableJetifier=true

推荐答案

应用中使用的所有模块都必须一起迁移到AndroidX.您需要将要保留在支持库中的模块移动到新项目中,并且只能将其用作maven依赖项或AndroidX项目中的AAR.

All modules used in your app need to move to AndroidX together. You'd need to move your module you want to keep on Support Library into a new project and only use it as a maven dependency or AAR in your AndroidX project.

这篇关于有没有一种方法可以将AndroidX和使用支持库的子项目混合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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