ClassNotFoundException when using androidx.fragment.app.FragmentContainerView

前端 未结 2 1786
旧时难觅i
旧时难觅i 2020-12-20 14:46

I\'m trying to transition from using a FrameLayout to using FragmentContainerView and from the tutorials I\'ve seen, it should be pretty easy. Howe

2条回答
  •  时光说笑
    2020-12-20 15:21

    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 :

    #-------------------------------------------------
    # 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
    

    You won't need implementation 'androidx.fragment:fragment:1.2.5' if your applicatin crashes in release build.

提交回复
热议问题