在我的Android应用中,我使用AppCompatPreferenceActivity和PreferenceFragment实现了设置页面。在Crashlytics中,我发现在使用以下消息实例化PreferenceFragment时,许多设备崩溃了:
Unable to start activity ComponentInfo android.app.Fragment$InstantiationException: Unable to instantiate fragment: make sure class name exists, is public, and has an empty constructor that is public.
但是,我很确定在片段中我确实实现了一个空构造函数,并且PreferenceFragment和AppCompatPreferenceActivity都是“公共的”所以我应该怎样做才能防止它再次崩溃?
此外,我还将其纳入我的亲卫规则中:
-keep public class * extends android.preference.PreferenceFragment
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.support.v4.app.FragmentActivity