You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Xamarin.Android.Build.Tasks] use mono.android.jar only for $(AndroidCodegenTarget)=XAJavaInterop1 (#9813)
`mono.android.jar` and `mono.android.dex` are compiled with
`$(AndroidCodegenTarget)=XAJavaInterop1`. This causes problems if
you build a project with `$(AndroidCodegenTarget)=JavaInterop1`
as the wrong set of Java stubs will be used.
For example, `dotnet new maui` using NativAOT we can get a crash such as:
E .hellonativeaot: No implementation found for void mono.android.Runtime.register(java.lang.String, java.lang.Class, java.lang.String) (tried Java_mono_android_Runtime_register and Java_mono_android_Runtime_register__Ljava_lang_String_2Ljava_lang_Class_2Ljava_lang_String_2) - is the library loaded, e.g. System.loadLibrary?
Which is caused by `mono.android.Runtime.register()` being called by
`mono/android/view/View_OnClickListenerImplementor.java` which is
compiled with `$(AndroidCodegenTarget)=XAJavaInterop1`.
To fix this:
* Several places already check if `$(_AndroidUseMarshalMethods)=true`
and skip usage of `mono.android.jar`.
* Add an additional check to verify
`$(AndroidCodegenTarget)=XAJavaInterop1`
Previously, `$(AndroidCodegenTarget)` was also allowed to be blank and
default to `XAJavaInterop1`, but it seems better to explicitly set it.
I also updated `BuildTest2.NativAOT()` to verify that
`mono/android/views/View_OnClickListenerImplementor.java` is
generated on disk.
// When marshal methods or non-JavaPeerStyle.XAJavaInterop1 are in use we do not want to skip non-user assemblies (such as Mono.Android) - we need to generate JCWs for them during
444
+
// application build, unlike in Debug configuration or when marshal methods are disabled, in which case we use JCWs generated during Xamarin.Android
0 commit comments