0

MyActivity 是从 SherlockFragmentActivity 扩展而来的。我正在使用proguard。我的 project-proguard.tx 确实包含

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }

这是堆栈跟踪。奇怪的是,这看起来不像我的代码的问题。它追溯到支持库。

java.lang.RuntimeException: Unable to start activity        
ComponentInfo{com.mycom.mypack/com.mycom.mypack.MyActivity}:   
java.lang.RuntimeException: Parcel android.os.Parcel@422ba150: Unmarshalling unknown   
type code 1670681840 at offset 72204
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2146)
at android.app.ActivityThread.access$700(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4947)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@422ba150:    
Unmarshalling unknown type code 1670681840 at offset 72204
at android.os.Parcel.readValue(Parcel.java:2032)
at android.os.Parcel.readListInternal(Parcel.java:2235)
at android.os.Parcel.readArrayList(Parcel.java:1655)
at android.os.Parcel.readValue(Parcel.java:1986)
at android.os.Parcel.readMapInternal(Parcel.java:2226)
at android.os.Bundle.unparcel(Bundle.java:223)
at android.os.Bundle.getParcelable(Bundle.java:1165)
at android.app.Activity.onCreate(Activity.java:927)
at android.support.v4.app.FragmentActivity.onCreate(SourceFile:189)
at com.mycom.mypack.MyActivity.onCreate(SourceFile:296)
at android.app.Activity.performCreate(Activity.java:5207)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2085)
... 11 more

=====================

下面是 onSavedInstanceState() 和 onRestoreInstanceState(),以及 onCreate() 的一部分,在 onCreate() 中有一些从 savedInstanceState 读取的内容,所以我将其包含在此处。

private int recognize = 0;
private ArrayList<ToFree> to_free = null;

@Override
public void onCreate(Bundle savedInstanceState) {
......

if(savedInstanceState!=null)
{
  language_type = savedInstanceState.getInt("language_type");
  save_binary = savedInstanceState.getBoolean("save_binary", false);

  line_content =
    savedInstanceState.getParcelableArrayList("line_content");
}

......

if(bitmap != null && savedInstanceState != null)
{
  final float[] m;
  final ArrayList<FloatPoint> flow;
  final ArrayList<FloatPoint2> filler;

  {
    m = savedInstanceState.getFloatArray("matrix");
    flow = savedInstanceState.getParcelableArrayList("reading_flow");
    filler = savedInstanceState.getParcelableArrayList("filler");
    show_flow = savedInstanceState.getBoolean("show_flow");
  }

 .....
}


protected void onSaveInstanceState(Bundle outState) {
outState.putInt("language_type", language_type);
if(save_binary)
  outState.putBoolean("save_binary", save_binary);
outState.putBoolean("show_flow", show_flow);
if(line_content != null)
  outState.putParcelableArrayList("line_content", line_content);

if(to_free != null && !to_free.isEmpty())
  outState.putParcelableArrayList("to_free", to_free);
if(recognize != 0)
{
  outState.putInt("recognize", recognize);
  recognize = 0;
}

if(data != null && data.page != 0)
{
  outState.putInt("page", data.page);

  outState.putBoolean("running", data.running);

  outState.putInt("ret", data.ret);
  outState.putBoolean("rgb_set", data.rgb_set);
  data.page_saved = data.page;
}

if(bitmap != null)
{
  float[] m = imageView.get_matrix();
  outState.putFloatArray("matrix", m);

  ArrayList<FloatPoint> flow = imageView.get_point_list();
  if(flow != null && flow.size()>0)
    outState.putParcelableArrayList("reading_flow", flow);

  ArrayList<FloatPoint2> filler = imageView.get_point_pair_edit_list();
  if(filler != null && filler.size()>0)
    outState.putParcelableArrayList("filler", filler);
}

super.onSaveInstanceState(outState);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);

to_free = savedInstanceState.getParcelableArrayList("to_free");

recognize = savedInstanceState.getInt("recognize", 0);
int page = savedInstanceState.getInt("page", 0);
if(page != 0)
{
  data = new DataNative();
  data.rgb_set = false;
  data.running = savedInstanceState.getBoolean("running", false);
  data.ret = savedInstanceState.getInt("ret", 0);
  data.rgb_set = savedInstanceState.getBoolean("rgb_set", false);
}
4

0 回答 0