dotnet / dotnet/android

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

Open
#8,675 65 comments 0 reactions 0 assignees View on GitHub
Area: App Runtime
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 19h
Merged PRs (30d)
252

Description

### 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

```shell
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)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.