Migrating to AndroidX

#1

We have begun migrating all of the officially supported extensions to AndroidX. AndroidX is an improvement to the original Android Support Library, which is no longer maintained. All recent updates to Google Services such as Push, Games, Analytics and more are based on the AndroidX libraries. Facebook has also rolled out new versions of their SDK which only support AndroidX.

We will keep supporting the old versions of the extensions for as long as possible, but it is recommended that you migrate soon to not miss out on important bugfixes.

With this change it is extra important that you never depend directly on the master branch of any dependencies. You should always depend on a specific release to avoid breaking changes as the libraries get updated.

extension-camera
AndroidX: https://github.com/defold/extension-camera/archive/2.0.0.zip
Support Library: https://github.com/defold/extension-camera/archive/1.0.0.zip

extension-gpgs
AndroidX: https://github.com/defold/extension-gpgs/archive/2.0.0.zip
Support Library: https://github.com/defold/extension-gpgs/archive/1.3.3.zip

extension-push
AndroidX: https://github.com/defold/extension-push/archive/3.0.0.zip
Support Library: https://github.com/defold/extension-push/archive/2.0.2.zip

extension-facebook
AndroidX: https://github.com/defold/extension-facebook/archive/3.0.0.zip (uses Facebook SDK 7.1.0 for Android and SDK 6.5.1 for iOS)
Support Library: https://github.com/defold/extension-facebook/archive/2.6.0.zip (uses Facebook SDK 6.5.1 for Android and iOS)

extension-iac
extension-iap
extension-webview
extension-adinfo
extension-videoplayer-native
No dependency on the support libraries.

extension-firebase
Built using the Firebase C++ SDK (v 6.16.0). No dependency on support libraries.

We will update this post with additional libraries as we migrate them to AndroidX.

16 Likes

#2

Do you anticipate any breaking changes? Or should this be pretty much seamless?

0 Likes

#3

There should be no breaking changes. Android X libraries use new package names for all classes but should work the same as the old versions.

The problem is that you can’t mix old and new libraries, so either all of your dependencies need to migrate or none. We will handle migration of all our extensions, and we recommend or community to also migrate theirs.

It is usually just a matter of updating your dependency versions in build.gradle and then importing the AndroidX classes, like this:

1 Like

#4

In Defold 1.2.177 we will enabled support for the Android Jetifier tool to the Defold build servers to help with migration to AndroidX. The Jetifier tool is currently running on the beta server (https://build-stage.defold.com) and will be available on the main build server when 1.2.177 is released in about a week.

The Jetifier tool will automatically try to migrate dependencies defined in the build.gradle files of extensions and in .jar files in your project. The Jetifier tool is enabled as an application manifest setting for armv7 and arm64:

    armv7-android:
        context:
            ...
            jetifier: true

    arm64-android:
        context:
            ...
            jetifier: true

The online manifest generator has been updated to support the new setting:

https://britzl.github.io/manifestation/

2 Likes

Apple Spider (Casual arcade action)
Defold 1.2.177 has been released
I'm getting "contextResource cannot be null" as a bundling error. How do I fix this?
Defold 1.2.177 BETA
#5

Does this mean that if one extension doesn’t use AndroidX, in my case I think GameAnalytics doesn’t, the game cannot use the latest IAP, Firebase, GPGS, Push and Facebook extensions?

Update: It seems not! Using the manifest generator with GameAnalytics + all the above mentioned dependencies built fine.

0 Likes

#6

When you build with AndroidX/Jetifier enabled in the app manifest (we will make this a game.project option) gradle and the Android tools will try to migrate all gradle dependencies to AndroidX.

If GameAnalytics uses old support libraries or similar they will automatically become upgraded to their AndroidX equivalents when you build your project.

The problem is if your project contains Java code or .jar files which references old support support libraries in which case you need to manually migrate those or use the Android Jetifier tool to help with the migration.

1 Like

#7

So if i have a dependecy in build.gradle that use androidX.
I add jetifer true. And it should work? or i need some more steps?

 armv7-android:
        context:
            flags:      ["-std=c++11"]
            jetifier: true
    arm64-android:
        context:
            flags:      ["-std=c++11"]
            jetifier: true

It not help me.

 What went wrong:
Execution failed for task ':downloadDependencies'.
 This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
  The following AndroidX dependencies are detected: androidx.appcompat:appcompat:1.1.0, androidx.core:core:1.1.0, androidx.versionedparcelable:versionedparcelable:1.1.0, androidx.fragment:fragment:1.1.0, androidx.lifecycle:lifecycle-common:2.1.0, androidx.appcompat:appcompat-resources:1.1.0, androidx.customview:customview:1.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.lifecycle:lifecycle-viewmodel:2.1.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.activity:activity:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.collection:collection:1.1.0, androidx.viewpager:viewpager:1.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.arch.core:core-common:2.1.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.vectordrawable:vectordrawable-animated:1.1.0, androidx.lifecycle:lifecycle-runtime:2.1.0, androidx.vectordrawable:vectordrawable:1.1.0, androidx.savedstate:savedstate:1.0.0, androidx.annotation:annotation:1.1.0
0 Likes

#8

I understand. I need to add it to game manifest, not library manifest)
Thanks)

0 Likes

#9

Correct.It applies AndroidX to your entire project.

(PS We plan to move this to a checkbox in game.project)

2 Likes