Java – Is there a way to mix AndroidX and use sub-projects of supporting libraries?

Is there a way to mix AndroidX and use sub-projects of supporting libraries?… here is a solution to the problem.

Is there a way to mix AndroidX and use sub-projects of supporting libraries?

I

have an Android project and I want to upgrade to AndroidX.
However, I’m using a module that is shared between other apps that haven’t been migrated to AndroidX yet. I want to avoid forking code and prefer to use the module’s support library while upgrading the reset of the project to use AndroidX.

Now I can’t import any android.support.v7 class. So, for example, import android.support.v7.widget.AppCompatEditText; Fail.

I tried to revert the changes made to build.gradle via the migration tool in the module, but that didn’t stop the compilation issue.

But in my gradle.properties there is still :

android.useAndroidX=true
android.enableJetifier=true

Solution

All modules used in your app need to be migrated together to AndroidX. You need to move the module you want to keep in the support library to the new project and only use it as a Maven dependency or AAR in your AndroidX project.

Related Problems and Solutions