Migrating to Androidx

Dec 28, 2018

If your compileSdkVersion/targetSdkVersion is 28, you shall bump into the following error if you have yet to migrate to androidx.

Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from androidx.core:core:1.0.0-alpha3 AndroidManifest.xml:22:18-86 is also present at com.android.support:support-compat:28.0.0-alpha3 AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:6:5-40:19 to override. Migrate to AndroidX.

There might be a few ways to perform the migration. I use Android Studio 3.2 -> Refactor -> Migrate to AndroidX.

It works pretty well by updating all the namespace and updating the gradle files as well (using the latest version of androidx packages, including alpha version).

I bump into Failed to resolve variable '${animal.sniffer.version}' error as well, and it is probably caused by Glide (upgrade to version 4.8.0 seems to solve the issue).

// https://github.com/bumptech/glide/releases
// def glide_version = '4.7.1'
def glide_version = "4.8.0"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"

If the problem still persist, no harm trying File -> Invalidate Caches/Restart and Build -> Clean Project.

Also some minor issue with android-ktx, where it seems the function toBitmap is replaced by drawToBitmap (the documentation is yet to be updated).

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.