在4.2版本设备android中找不到Parcelable中的问题

时间:2015-08-31 03:55:46

标签: java android noclassdeffounderror parcelable

我想在我的应用程序中集成Parcelable类。以下是我的代码

GetSecrateKey.java

import android.os.Parcel;
import android.os.Parcelable;

public class GetSecrateKey implements Parcelable {

public String success = "";
public String message = "";

public String hasval="";

public String accsesskey="";

public String tenants_id="";
public String is_active="";

public String getIs_active() {
    return is_active;
}

public void setIs_active(String is_active) {
    this.is_active = is_active;
}

public String getTenants_id() {
    return tenants_id;
}

public void setTenants_id(String tenants_id) {
    this.tenants_id = tenants_id;
}

public  GetSecrateKey() {

}


public String getHasval() {
    return hasval;
}


public void setHasval(String hasval) {
    this.hasval = hasval;
}


public String getAccsesskey() {
    return accsesskey;
}


public void setAccsesskey(String accsesskey) {
    this.accsesskey = accsesskey;
}


public String getSuccess() {
    return success;
}

public void setSuccess(String success) {
    this.success = success;
}



public String getMessage() {
    return message;
}

public void setMessage(String message) {
    this.message = message;
}

@Override
public int describeContents() {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    // TODO Auto-generated method stub
    dest.writeString(success);
    dest.writeString(message);
    dest.writeString(accsesskey);
    dest.writeString(hasval);
    dest.writeString(tenants_id);
    dest.writeString(is_active);

}

public  static final Creator<GetSecrateKey> CREATOR = new Creator<GetSecrateKey>() {

    @Override
    public GetSecrateKey[] newArray(int size) {
        return new GetSecrateKey[size];
    }

    @Override
    public GetSecrateKey createFromParcel(Parcel source) {
        return new GetSecrateKey(source);
    }
};

public GetSecrateKey(Parcel in) {
    success = in.readString();
    message = in.readString();
    accsesskey = in.readString();
    hasval=in.readString();
    tenants_id=in.readString();
    is_active=in.readString();

  }

} 

MAin.java

public class MAin extends Activity {
GetSecrateKey mGetSecrateKey;
 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_login);

   mGetSecrateKey=new GetSecrateKey();
}

当我运行我的代码时,它在我的平板电脑4.2设备中给出了错误,如下所示   mGetSecrateKey =新的GetSecrateKey();

    java.lang.ExceptionInInitializerError
        at pkg.android.rootways.worldofrental.LoginActivity.onCreate(LoginActivity.java:89)
        at android.app.Activity.performCreate(Activity.java:5283)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
        at android.app.ActivityThread.access$700(ActivityThread.java:150)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:175)
        at android.app.ActivityThread.main(ActivityThread.java:5279)
        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:1102)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NoClassDefFoundError: pkg.android.rootways.worldofrental.parser.GetSecrateKey$1
        at pkg.android.rootways.worldofrental.parser.GetSecrateKey.<clinit>(GetSecrateKey.java:95)
                    pkg.android.rootways.worldofrental.Main.onCreate(LoginActivity.java:89)

0 个答案:

没有答案