奇怪"在解组时没有找到班级"错误

时间:2014-10-20 19:44:03

标签: android unmarshalling parcelable galaxy

所以我在我的应用程序中遇到了一个奇怪的类在解组错误时找不到。每次我在意图中使用parcelable对象激活一个活动我得到这个错误但是一切似乎都运行正常。我写了一个简单的应用程序来测试parcels和这个错误。该应用程序有一个按钮,它使用以下代码启动新活动:

public void onClick(View v) {
    Intent i = new Intent(getActivity(), Display.class);
    Data data = new Data(49, "Foobar");
    i.putExtra("data", data);
    startActivity(i);
}

当我点击按钮时,我会得到looong错误/堆栈跟踪,您将在此帖子的底部找到它。有趣的是,我甚至不需要处理新活动中的捆绑/包裹/数据来获得此错误。我开始相信我的手机(Galaxy S3 LTE)与包裹有点不同,因为我还没能用模拟器或S2重现这个错误。

是否有其他人遇到过这种行为或者有什么想法我可以尝试解决这个问题?

我使用的宗地对象如下:

public class Data implements Parcelable {
    private int mNumber;
    private String mText;

    @Override
    public int describeContents() {
        return 0;
    }
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mNumber);
        dest.writeString(mText);
    }
    public Data(Parcel in) {
        mNumber = in.readInt();
        mText = in.readString();
    }
    public static final Creator<Data> CREATOR = new Creator<Data>() {
        @Override
        public Data createFromParcel(Parcel source) {
            return new Data(source);
        }
        @Override
        public Data[] newArray(int size) {
            return new Data[size];
        }
    };
    public int getNumber() {
        return mNumber;
    }
    public String getText() {
        return mText;
    }
    public Data(int num, String s) {
        mNumber = num;
        mText = s;
    }
}

和错误:

10-20 22:15:22.605    2378-2389/? E/DatabaseUtils﹕ Writing exception to parcel
    java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
            at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13101)
            at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
            at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
            at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
            at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
            at android.os.Binder.execTransact(Binder.java:388)
            at dalvik.system.NativeStart.run(Native Method)
10-20 22:15:22.610    2378-2997/? E/Parcel﹕ Class not found when unmarshalling: com.foobar.parceltest.Data
    java.lang.ClassNotFoundException: com.foobar.parceltest.Data
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:204)
            at java.lang.Class.forName(Class.java:169)
            at android.os.Parcel.readParcelableCreator(Parcel.java:2091)
            at android.os.Parcel.readParcelable(Parcel.java:2055)
            at android.os.Parcel.readValue(Parcel.java:1971)
            at android.os.Parcel.readMapInternal(Parcel.java:2255)
            at android.os.Bundle.unparcel(Bundle.java:223)
            at android.os.Bundle.getString(Bundle.java:1082)
            at android.content.Intent.getStringExtra(Intent.java:4961)
            at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3761)
            at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:4981)
            at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3163)
            at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3119)
            at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:157)
            at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2115)
            at android.os.Binder.execTransact(Binder.java:388)
            at dalvik.system.NativeStart.run(Native Method)
     Caused by: java.lang.NoClassDefFoundError: com/foobar/parceltest/Data
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:204)
            at java.lang.Class.forName(Class.java:169)
            at android.os.Parcel.readParcelableCreator(Parcel.java:2091)
            at android.os.Parcel.readParcelable(Parcel.java:2055)
            at android.os.Parcel.readValue(Parcel.java:1971)
            at android.os.Parcel.readMapInternal(Parcel.java:2255)
            at android.os.Bundle.unparcel(Bundle.java:223)
            at android.os.Bundle.getString(Bundle.java:1082)
            at android.content.Intent.getStringExtra(Intent.java:4961)
            at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3761)
            at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:4981)
            at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3163)
            at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3119)
            at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:157)
            at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2115)
            at android.os.Binder.execTransact(Binder.java:388)
            at dalvik.system.NativeStart.run(Native Method)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.foobar.parceltest.Data" on path: .
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:204)
            at java.lang.Class.forName(Class.java:169)
            at android.os.Parcel.readParcelableCreator(Parcel.java:2091)
            at android.os.Parcel.readParcelable(Parcel.java:2055)
            at android.os.Parcel.readValue(Parcel.java:1971)
            at android.os.Parcel.readMapInternal(Parcel.java:2255)
            at android.os.Bundle.unparcel(Bundle.java:223)
            at android.os.Bundle.getString(Bundle.java:1082)
            at android.content.Intent.getStringExtra(Intent.java:4961)
            at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:3761)
            at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:4981)
            at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3163)
            at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3119)
            at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:157)
            at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2115)
            at android.os.Binder.execTransact(Binder.java:388)
            at dalvik.system.NativeStart.run(Native Method)

0 个答案:

没有答案