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

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)

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 36 (19 by maintainers)

Most upvoted comments

re: @ciuffo81

@jasells Could you give me the access to the repo? Please I have the same issue.

I’m not sure what your issue is, but odds are > 90% not this issue if you have an unsatisfied link error. Odds are you’re simply missing a package. However, if you have a similar situation where you have a native Android service launching from a package lib, then the following snippet to a new activity that essentially registers the service with app-code (or vice-versa) so it can call back was the solution. You’ll need to change the process name to match your situation unless you’re also dealing with Stripe.Terminal SDK.

  [Activity(Label = "do not use", Exported = false, Process = "com.stripe.cots.aidlservice")]
   public class JonpDummyActivity : Activity { }

@grendello: this feels unrelated to 06b1d7f82143fb32b1397b3657de5b22fdcfdf7c, and more related to the fact that their service is in a separate process:

    <activity android:name="my.Activity.Name" android:exported="false" android:process="com.excample.process_name" android:theme="@style/Theme.CotsApp">
      <intent-filter>
        <action android:name="android.nfc.action.NDEF_DISCOVERED" />
        <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
    </activity>
    <service android:name="some.external.ServiceType" android:exported="false" android:process="com.excample.process_name" />

Now that I know I need all the permissions – my bad for not properly reading README.md – I am able to repro the crash.

@bloomer-joe: a repro would also be handy.

@grendello , @jonpryor

I am a team-mate of @bloomer-joe and have been following the issue, and trying to resolve it as well.

I posted a repro-repo here and gave you access. I can add others or make it public if that helps.

@jasells Could you give me the access to the repo? Please I have the same issue.

@bloomer-joe: a repro would also be handy.

@grendello , @jonpryor

I am a team-mate of @bloomer-joe and have been following the issue, and trying to resolve it as well.

I posted a repro-repo here and gave you access. I can add others or make it public if that helps.