GCX-HCI / ThirtyInch

a MVP library for Android favoring a stateful Presenter
Apache License 2.0
1.03k stars 101 forks source link

Crash using AndroidX with ProGuard enabled #163

Open Syex opened 6 years ago

Syex commented 6 years ago

@passsy already added a workaround for the BackstackReader with AndroidX for #149.

However, with ProGuard enabled I encountered the following issue:

Fatal Exception: java.lang.NoSuchMethodError: No virtual method isInBackStack()Z in class Landroidx/e/a/d; or its super classes (declaration of 'androidx.e.a.d' appears in /data/app/de.memorian.gzg-Mcx2ZyPo55208bHcZq319Q==/base.apk)
       at androidx.core.app.BackstackReader.isInBackStack(BackstackReader.java:23)
       at net.grandcentrix.thirtyinch.TiFragment.isFragmentInBackstack(TiFragment.java:235)
       at net.grandcentrix.thirtyinch.TiFragment.net.grandcentrix.thirtyinch.internal.TiFragmentDelegate.onDestroy_afterSuper(TiFragment.java:10204)
       at androidx.fragment.app.FragmentManagerImpl.androidx.fragment.app.Fragment.performDestroy(FragmentManager.java:16699)

Adding a ProGuard rule -keep class androidx.** { *; } resp. -keep class androidx.fragment.app.Fragment { *; }

fixed the problem.

We could add this ProGuard rule to the library ProGuard rules to avoid it for now.

StefMa commented 6 years ago

Excluding everything (keep class androidx.** { *; }) of shrinking/obfuscating sounds a little bit aggressive to me... 🤔

Syex commented 6 years ago

The only fix I know so far.

Edit: Updated post, keeping the Fragment class is enough.