-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[generator] restore [RegisterAttribute]
for *Implementor types
#1149
Merged
jonpryor
merged 1 commit into
dotnet:main
from
jonathanpeppers:TheReturnOfTheRegisterAttribute
Oct 9, 2023
Merged
[generator] restore [RegisterAttribute]
for *Implementor types
#1149
jonpryor
merged 1 commit into
dotnet:main
from
jonathanpeppers:TheReturnOfTheRegisterAttribute
Oct 9, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jpobst
approved these changes
Oct 9, 2023
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>(...); } So we could do `android.**`, 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?
55fdc0e
to
ca40f3a
Compare
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this pull request
Oct 9, 2023
Added a test at: dotnet/android#8407 |
jonathanpeppers
added a commit
to dotnet/android
that referenced
this pull request
Oct 10, 2023
Changes: dotnet/java-interop@8e63cc8...ed63d89 * [generator] restore `[RegisterAttribute]` for *Implementor types Other changes: * Added test to verify `Lmono/android/view/View_OnClickListenerImplementor;` exists after a build using `AndroidLinkMode=r8`. dotnet/java-interop#1149
jonathanpeppers
added a commit
to dotnet/android
that referenced
this pull request
Oct 10, 2023
Changes: dotnet/java-interop@8e63cc8...ed63d89 * [generator] restore `[RegisterAttribute]` for *Implementor types Other changes: * Added test to verify `Lmono/android/view/View_OnClickListenerImplementor;` exists after a build using `AndroidLinkMode=r8`. dotnet/java-interop#1149
jonathanpeppers
added a commit
to dotnet/android
that referenced
this pull request
Oct 17, 2023
Changes: dotnet/java-interop@8e63cc8...ed63d89 * [generator] restore `[RegisterAttribute]` for *Implementor types Other changes: * Added test to verify `Lmono/android/view/View_OnClickListenerImplementor;` exists after a build using `AndroidLinkMode=r8`. dotnet/java-interop#1149
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: dotnet/android#8337
A customer's app with the code:
Crashes with
-c Release -p:AndroidLinkMode=r8
with:Which, can be solved by adding your own
proguard
rules like:In a91ae7f, we thought (incorrectly):
proguard_xamarin.cfg
has the entry:So we could do
android.**
, 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?