Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Material] Slider.Change crashes at runtime in Release with R8 (NoSuchMethodError)

Aperta
#1,549 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
android, csharp

Direzione di ricerca

Start with the generated Google.Android.Material.Slider.AddOnChangeListener entry point and reproduce the failure using the listed net10.0-android Release commands with full trimming and R8 enabled. Compare the failing build with the supplied ProGuard.cfg keep rule; done means subscribing to Slider.Change works at runtime without application-specific keep rules.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Android framework version

net10.0-android

Affected platform version

  • .NET SDK 10.0.401
  • .NET for Android workload 36.1.69
  • Xamarin.Google.Android.Material 1.14.0.6
  • Windows 10.0.26200

Description

Subscribing to the normal C# Slider.Change event works in Debug, but a Release build using R8 crashes at runtime when the event is registered.

The Release build itself succeeds. At runtime, the generated event binding calls Slider.addOnChangeListener(BaseOnChangeListener), but R8 has removed or changed that method signature.

This is related to #230 and #1335, but it is a different failure mode: the Change event now exists and compiles; it fails only at runtime after R8 processes the app.

Expected: Slider.Change can be subscribed to in an R8-enabled Release build without application-specific keep rules.

Actual: the app terminates with NoSuchMethodError while adding the event handler.

Steps to Reproduce

  1. Create a net10.0-android application.
  2. Reference Xamarin.Google.Android.Material 1.14.0.6.
  3. Enable full trimming and R8 for Release:
<PropertyGroup>
  <TargetFramework>net10.0-android</TargetFramework>
  <TrimMode>full</TrimMode>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
  <AndroidLinkTool>r8</AndroidLinkTool>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Xamarin.Google.Android.Material" Version="1.14.0.6" />
</ItemGroup>
  1. Add a Material Slider to the activity layout.
  2. Subscribe to its generated C# event:
var slider = FindViewById<Google.Android.Material.Slider.Slider>(Resource.Id.slider)!;
slider.Change += (_, _) => { };
  1. Build and install Release:
dotnet build -c Release
adb install -r bin/Release/net10.0-android/com.companyname.AndroidMaterialSliderRepro-Signed.apk
  1. Launch the app. It crashes while registering the event handler.

Minimal reproduction: AndroidMaterialSliderRepro.zip

Did you find any workaround?

Yes. Keeping the Material slider classes prevents the crash:

-keep class com.google.android.material.slider.** { *; }

Placing that rule in the project's ProGuard.cfg makes the same Release build run successfully.

Relevant log output

java.lang.NoSuchMethodError: no non-static method
"Lcom/google/android/material/slider/Slider;.addOnChangeListener(Lcom/google/android/material/slider/BaseOnChangeListener;)V"
    at Google.Android.Material.Slider.Slider.AddOnChangeListener(IOnChangeListener listener)
    at Java.Interop.EventHelper.AddEventHandler(...)
    at Google.Android.Material.Slider.Slider.add_Change(EventHandler`1)
    at AndroidMaterialSliderRepro.MainActivity.OnCreate(Bundle savedInstanceState)
Lingua principale
C#
Stelle
319
Fork
73
Merge medio
2g 11h
PR unite (30g)
8

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/android-libraries

Tutte le issue di dotnet/android-libraries

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.