【发布时间】:2014-01-24 02:22:55
【问题描述】:
对于我正在处理的某些应用程序,对于 API 级别 19 的设备,我遇到了异常
Caused by: java.lang.RuntimeException: Subclasses of PreferenceActivity must override isValidFragment(String) to verify that the Fragment class is valid! com... has not checked if fragment com...$. is valid.
然后,我发现对于那些应用程序,Android 框架 protected boolean isValidFragment(String fragmentName) 被调用,其中包含代码
if (getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.KITKAT) {
throw new RuntimeException(
"Subclasses of PreferenceActivity must override isValidFragment(String)"
+ " to verify that the Fragment class is valid! " + this.getClass().getName()
+ " has not checked if fragment " + fragmentName + " is valid.");
} else {
return true;
}
然后我尝试复制错误
我从Preferences Activity Example 获取了我的示例应用程序代码
并在清单中添加了<uses-sdk android:targetSdkVersion="19" /> 行。
但奇怪的是,我没有收到错误消息(在这种情况下没有调用 isValidFragment())。
所以请告诉我如何在我的示例应用中复制该错误。
【问题讨论】:
-
如果我写了一个应用程序并在 3 年前左右发布,为什么不能让 Google 运行而设置此 ANR
标签: android exception android-fragments sdk android-activity