rust-mobile/android-activity

No implementation found for `long com.google.androidgamesdk.GameActivity.initializeNativeCode`

torokati44 opened this issue · 6 comments

After updating android-activity from 0.4.2 to 0.4.3, and androidx.games:games-activity from 1.1.0 to 2.0.2, I get this error when I'm creating the GameActivity subclass instance:

No implementation found for long com.google.androidgamesdk.GameActivity.initializeNativeCode(java.lang.String, java.lang.String, java.lang.String, android.content.res.AssetManager, byte[], android.content.res.Configuration) (tried Java_com_google_androidgamesdk_GameActivity_initializeNativeCode and Java_com_google_androidgamesdk_GameActivity_initializeNativeCode__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Landroid_content_res_AssetManager_2_3BLandroid_content_res_Configuration_2)

AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for long com.google.androidgamesdk.GameActivity.initializeNativeCode(java.lang.String, java.lang.String, java.lang.String, android.content.res.AssetManager, byte[], android.content.res.Configuration) (tried Java_com_google_androidgamesdk_GameActivity_initializeNativeCode and Java_com_google_androidgamesdk_GameActivity_initializeNativeCode__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Landroid_content_res_AssetManager_2_3BLandroid_content_res_Configuration_2)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at com.google.androidgamesdk.GameActivity.initializeNativeCode(Native Method)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at com.google.androidgamesdk.GameActivity.onCreate(GameActivity.java:322)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at rs.ruffle.FullscreenNativeActivity.onCreate(FullscreenNativeActivity.java:221)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:8342)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:8321)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3625)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3781)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2306)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:106)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.os.Looper.loopOnce(Looper.java:201)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:288)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7918)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
08-02 15:09:41.127 15805 15805 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

This is with: https://github.com/torokati44/ruffle-android/actions/runs/5739934997
The last working build was: https://github.com/torokati44/ruffle-android/actions/runs/5739934006

This is all that's changed between the working and crashing builds: ruffle-rs/ruffle-android@99aae5f

EDIT: I've updated the "last working build" so the regressing diff is smaller and more relevant ... again.

Apart from changing these two version numbers, should I make any code changes to make it work?
Such as, implement GameActivity.initializeNativeCode?

Ooooohhh, my mistake, I thought the 0.4.3 release already included the switch to GameActivity 2.0.2... 🤦

rib commented

ah right, yeah, the update to GameActivity 2.0.2 will be part of a 0.5 release, hopefully soon.

I did consider releasing the update as part of a 0.4 release (since it's ambiguous whether we should treat it as a semver break for the crate) but since there were other reasons for needing a 0.5 release anyway I decided I'd include it in 0.5 instead.

Before releasing 0.5 I have an input API update I also want to land for exposing KeyCharacterMap bindings that enable support for unicode character mapping. This required a change to the .input_events() API.

I'd like to have 0.5 available for Winit 0.29 which should be released soonish

Was GameActivity 1.2[.2] ever supported BTW? Because I tried that too, with android-activity 0.4.2, and got the same error.

rib commented

#88 was the first time doing an update since I first bootstrapped GameActivity support.

Previously GameActivity was based on a snapshot from Git taken on May 25th 2022, and required several patches to even get it to compile. The base commit from https://android.googlesource.com/platform/frameworks/opt/gamesdk/ was e8c66318443e5c864395725d7e4416d5b46242f8 I believe.

This fell between 1.1.0 and 1.2.0, but yeah that was before they enabled "derived classes of GameActivity to handle native library loading" which I guess is when initializeNativeCode was added.

We need to maintain fewer patches to the GameActivity code now so I'd guess it should be easier to track releases too.

It's nicer that this update corresponds to a specific 2.0.2 release.

I see, thanks! I'll wait for winit 0.29 and android-activity 0.5 before switching to GameActivity 2.0.2 then, skipping the 1.2 series. I have no issues with 1.1, just wanted to keep up with the times!