ClassNotFoundException when using androidx.fragment.app.FragmentContainerView
That's in androidx.fragment
1.2.0 or higher:
implementation "androidx.fragment:fragment:1.2.0"
Thanks to @Salam El-Banna and his link, I found that in case an application crashes in release
build we should add in proguard-rules.pro
(one or two lines, depending on android:name
in <FragmentContainerView>
:
#-------------------------------------------------
# JetPack Navigation
# This fixes:
# Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment androidx.navigation.fragment.NavHostFragment: make sure class name exists
# Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists
#-------------------------------------------------
-keepnames class androidx.navigation.fragment.NavHostFragment
-keepnames class com.google.android.gms.maps.SupportMapFragment