Skip to content

.NET 7 UnsatisfiedLinkError to native OnCreate() coming from Java Binding #8675

Description

@bloomer-joe

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

Android 12

Description

App shows UnsatisfiedLinkError after migrating from Mono.Android v12.0 (API 31) to net7.0-android. The app contains multiple projects to link in 3rd party Java bindings. The app (including bindings) runs smoothly except for one feature. When that feature is called from the Java binding, it attempts to call the app's OnCreate() and fails.

It seems as if OnCreate() might not be registered or otherwise accessible from the Java code,.

Advice from these documents was introduced as a possible fix, but the error persists:
https://learn.microsoft.com/en-us/dotnet/maui/android/internals/java-interop?view=net-maui-7.0#registration
https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/native-embedding?view=net-maui-7.0

Due to the nature of the 3rd party library, this bug is only caught in Release mode, as the library's Debug mode implementation does not allow hardware activation of the NFC reader.

Steps to Reproduce

No repro.

Did you find any workaround?

No response

Relevant log output

java.lang.UnsatisfiedLinkError: No implementation found for void crc6443da931ec5bafba4.MainApplication.n_onCreate() (tried Java_crc6443da931ec5bafba4_MainApplication_n_1onCreate and Java_crc6443da931ec5bafba4_MainApplication_n_1onCreate__)
                                                                                                    	at crc6443da931ec5bafba4.MainApplication.n_onCreate(Native Method)
                                                                                                    	at crc6443da931ec5bafba4.MainApplication.onCreate(MainApplication.java:25)
                                                                                                    	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211)
                                                                                                    	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6715)
                                                                                                    	at android.app.ActivityThread.access$1300(ActivityThread.java:250)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2045)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                    	at android.os.Looper.loop(Looper.java:288)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:7829)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:982)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions