问题
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.
Right now I cannot import any android.support.v7
classes. So for example import android.support.v7.widget.AppCompatEditText;
fails.
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.
However in my gradle.properties
still has:
android.useAndroidX=true
android.enableJetifier=true
回答1:
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.
回答2:
If you use multi-module project with androidX
[About] and want to use a module with support library
you can try to create gradle.properties
file inside module folder and define
android.useAndroidX=false
android.enableJetifier=false
Moreover I would recommend you to create gradle.properties
for every module to configure your project
[AndroidX and support compatibility]
来源:https://stackoverflow.com/questions/52993336/is-there-a-way-to-mix-androidx-and-a-subproject-that-uses-the-support-library