xamarin/Xamarin.Forms

[Bug] Android issue java.lang.NoClassDefFoundError

Open

#8,301 opened on Oct 30, 2019

 (10 comments) (1 reaction) (0 assignees)C# (1,926 forks)batch import
has-stacktracehelp wantedi/highinactivep/Androidt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

Hi, my Xamarin.Forms application is crashing on some Android devices. I have found some posts about similar issue in native development. The solution is to change in gradle ResolutionStrategy, however I don't know how to apply this fix to Xamarin development.

Here is possible fix: https://stackoverflow.com/questions/53161063/viewcompatonunhandledkeyeventlistener-on-setcontentview

Steps to Reproduce

Just run the application and on some devices it crashes with the following logs:

10-29 18:31:03.794: I/zygote64(15441): Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
10-29 18:31:03.794: I/zygote64(15441):   at void android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, android.support.v4.view.OnApplyWindowInsetsListener) (:-1)
10-29 18:31:03.794: I/zygote64(15441):   at android.view.ViewGroup android.support.v7.app.AppCompatDelegateImpl.createSubDecor() (:-1)
10-29 18:31:03.794: I/zygote64(15441):   at void android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor() (:-1)
10-29 18:31:03.794: I/zygote64(15441):   at void android.support.v7.app.AppCompatDelegateImpl.initWindowDecorActionBar() (:-1)
10-29 18:31:03.794: I/zygote64(15441):   at android.support.v7.app.ActionBar android.support.v7.app.AppCompatDelegateImpl.getSupportActionBar() (:-1)
10-29 18:31:03.794: I/zygote64(15441):   at void android.support.v7.app.AppCompatDelegateImpl.setSupportActionBar(android.support.v7.widget.Toolbar) (:-1)
10-29 18:31:03.794: I/zygote64(15441):   at void android.support.v7.app.AppCompatActivity.setSupportActionBar(android.support.v7.widget.Toolbar) (:-1)
10-29 18:31:03.794: I/zygote64(15441):   at void md536637be26cc67c3c700931937b0a7da2.MainActivity.n_onCreate(android.os.Bundle) (:-2)
10-29 18:31:03.794: I/zygote64(15441):   at void md536637be26cc67c3c700931937b0a7da2.MainActivity.onCreate(android.os.Bundle) (:-1)
10-29 18:31:03.794: I/zygote64(15441):   at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
10-29 18:31:03.794: I/zygote64(15441):   at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1213)
10-29 18:31:03.794: I/zygote64(15441):   at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2779)
10-29 18:31:03.794: I/zygote64(15441):   at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2904)
10-29 18:31:03.794: I/zygote64(15441):   at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
10-29 18:31:03.794: I/zygote64(15441):   at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1596)
10-29 18:31:03.794: I/zygote64(15441):   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
10-29 18:31:03.794: I/zygote64(15441):   at void android.os.Looper.loop() (Looper.java:164)
10-29 18:31:03.794: I/zygote64(15441):   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6600)
10-29 18:31:03.794: I/zygote64(15441):   at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
10-29 18:31:03.794: I/zygote64(15441):   at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
10-29 18:31:03.794: I/zygote64(15441):   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:772)

Packages that I use:

<ItemGroup>
    <Reference Include="Mono.Android" />
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="PropertyChanged.Fody" Version="3.1.3" PrivateAssets="all" />
    <PackageReference Include="Prism.DryIoc.Forms" Version="7.0.0.396" />
    <PackageReference Include="Crashlytics">
      <Version>1.5.0</Version>
    </PackageReference>
    <PackageReference Include="Fabric">
      <Version>1.5.0</Version>
    </PackageReference>
    <PackageReference Include="Plugin.StoreReview">
      <Version>2.0.0.5</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Analytics">
      <Version>71.1630.0</Version>
    </PackageReference>
    <PackageReference Include="Xam.Plugin.Geolocator">
      <Version>4.5.0.6</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Messaging">
      <Version>71.1740.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Forms">
      <Version>4.2.0.848062</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Forms.Maps">
      <Version>4.2.0.848062</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.GooglePlayServices.Analytics">
      <Version>71.1608.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.GooglePlayServices.Basement">
      <Version>71.1620.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.GooglePlayServices.Maps">
      <Version>71.1610.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.GooglePlayServices.Tasks">
      <Version>71.1601.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Common">
      <Version>71.1610.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.GooglePlayServices.Base">
      <Version>71.1610.0</Version>
    </PackageReference>
    <PackageReference Include="Xamarin.Firebase.Iid">
      <Version>71.1710.0</Version>
    </PackageReference>
  </ItemGroup>

Expected Behavior

Application should work properly on all supported Android devices.

Actual Behavior

It causes crash on some Android devices.

Basic Information

  • Last known good version: -
  • IDE: Visual Studio for Mac 8.3.4 (#8)
  • Platform Target Frameworks:
    • Android API 29
  • Nuget Packages: 4.2.0.848062
  • Affected Devices: some Android devices, not sure what's the root cause.

Contributor guide