两个关于View.SavedState 的异常分析

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.*****/com.******.RootActivity}: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ScrollView$SavedState

从错误分析来看应该layout 文件中 有一个ScrollView 的 id 与其他 View 的 id 发生了重复造成的

Unable to start activity ComponentInfo{com.*****/com.*******.UnlockGesturePasswordActivity}: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.view.View$BaseSavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/gesturepwd_unlock_lockview. Make sure other views do not use the same id.
开始以为与上面一样,有View 的 id 发生了重复。 后来搜索一下并没有发现。 后来查看code 发现
SavedState 没有创建CREATOR 导致的

 
  
private static class SavedState extends BaseSavedState {
public static final Parcelable.Creator CREATOR = new Creator() {
   public SavedState createFromParcel(Parcel in) {
      return new SavedState(in);
   }

   public SavedState[] newArray(int size) {
      return new SavedState[size];
   }
};



你可能感兴趣的:(android,Application)