Skip to content
This repository was archived by the owner on Nov 9, 2026. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dotnet/java-interop
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8e63cc8d
Choose a base ref
...
head repository: dotnet/java-interop
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ed63d890
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on Oct 9, 2023

  1. [generator] restore [RegisterAttribute] for *Implementor types (#1149)

    Fixes: dotnet/android#8337
    
    A customer's app with the code:
    
    	SetContentView(Resource.Layout.activity_main);
    	FindViewById<Button>(Resource.Id.asd).Click += MainActivity_Click;
    
    Crashes with `-c Release -p:AndroidLinkMode=r8` with:
    
    	java.lang.RuntimeException: Unable to start activity ComponentInfo{com.companyname.New_folder/crc64abe8cc9139195b67.MainActivity}: java.lang.ClassNotFoundException: android.view.View_IOnClickListenerImplementor
    	    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3644)
    	    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3781)
    	    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
    	    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
    	    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    	    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2306)
    	    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:7918)
    	    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:936)
    	Caused by: java.lang.ClassNotFoundException: android.view.View_IOnClickListenerImplementor
    	    at crc64abe8cc9139195b67.MainActivity.n_onCreate(Native Method)
    	    at crc64abe8cc9139195b67.MainActivity.onCreate(MainActivity.java:30)
    	    at android.app.Activity.performCreate(Activity.java:8342)
    	    at android.app.Activity.performCreate(Activity.java:8321)
    	    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
    	    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3625)
    	    ... 12 more
    
    Which, can be solved by adding your own `proguard` rules like:
    
    	-keep class android.view.View_IOnClickListenerImplementor { *; }
    
    In a91ae7f, we thought (incorrectly):
    
    > Additionally, stop emitting the `[Register]` attribute for
    > `*Implementor` classes:
    >
    >     [global::Android.Runtime.Register ("mono/android/view/View_OnFocusChangeListenerImplementor")]
    >     partial class IOnFocusChangeListenerImplementor {/* … */}
    >
    > The `[Register]` attribute is not needed, because `*Implementor`
    > classes are generated internal implementation details.
    
    `proguard_xamarin.cfg` has the entry:
    
    	-keep class mono.android.** { *; <init>(...); }
    
    We could do `-keep class android.**` [^0], but that would certainly
    preserve way too much!
    
    For now, let's just restore `[Register]` to revisit this issue at a
    later date -- maybe .NET 9?
    
    [^0]: Why is `View_IOnClickListenerImplementor` in the `android.view`
          package?!  Because package name generation for Java Callable
          Wrappers is special-cased for `Mono.Android` to simply
          [lowercase the namespace name][0], which applies only if the 
          type *doesn't* have `[RegisterAttribute]`!
    
    [0]: https://github.com/xamarin/java.interop/blob/8e63cc8da1882cadc7db329bfa6cafb6f914769f/src/Java.Interop.Tools.TypeNameMappings/Java.Interop.Tools.TypeNameMappings/JavaNativeTypeManager.cs#L200-L209
    jonathanpeppers authored Oct 9, 2023
    Configuration menu
    Copy the full SHA
    ed63d89 View commit details
    Browse the repository at this point in the history
Loading