Proguard causing runtime exception with Android Navigation Component

前端 未结 4 919
臣服心动
臣服心动 2020-12-09 02:18

I\'m experiencing this crash when using proguard after integrating the NavigationComponent (android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha01) into

4条回答
  •  孤街浪徒
    2020-12-09 02:29

    My issue was that I was using the fragment name on the layout. After R8, the names are obfuscated causing the issue.

    
    

    In my case, the solution was to keep only the name in the Proguard file, as such:

    #-------------------------------------------------
    # JetPack Navigation
    # This fixes: Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment androidx.navigation.fragment.NavHostFragment: make sure class name exists
    #-------------------------------------------------
    -keepnames class androidx.navigation.fragment.NavHostFragment
    

提交回复
热议问题