Is there a way to mix AndroidX and a subproject that uses the support library?

让人想犯罪 __ 提交于 2020-12-02 11:48:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!