android.os.BadParcelableException:解组时出现 ClassNotFoundException:
android.os.BadParcelableException: ClassNotFoundException when unmarshalling:
我不知道为什么会这样,我无法重现它。
它在控制台中。
我真的很抱歉只输入代码和日志猫,但我什至无法阅读logcat,我之前没有遇到过这样的问题,我什至不知道在哪里首先。
任何帮助将不胜感激。
这是日志猫,
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: bitsie.playmee.musicplayer.free.classes.SongDetails
at android.os.Parcel.readParcelableCreator(Parcel.java:2147)
at android.os.Parcel.readParcelable(Parcel.java:2097)
at android.os.Parcel.readValue(Parcel.java:2013)
at android.os.Parcel.readListInternal(Parcel.java:2343)
at android.os.Parcel.readArrayList(Parcel.java:1703)
at android.os.Parcel.readValue(Parcel.java:2034)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2314)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:1273)
at android.support.v4.app.FragmentManagerImpl.throwException(Unknown Source)
beginTransaction
putFragment
getFragment
saveFragmentInstanceState
dump
makeOpenCloseAnimation
makeFadeAnimation
loadAnimation
moveToState
moveToState
moveToState
addFragment
removeFragment
findFragmentById
findFragmentByTag
enqueueAction
allocBackStackIndex
setBackStackIndex
popBackStackState
restoreAllState
attachActivity
dispatchConfigurationChanged
dispatchCreateOptionsMenu
dispatchPrepareOptionsMenu
dispatchOptionsItemSelected
at android.support.v4.app.FragmentManagerImpl.throwException(Unknown Source)
beginTransaction
putFragment
getFragment
saveFragmentInstanceState
dump
makeOpenCloseAnimation
makeFadeAnimation
loadAnimation
moveToState
moveToState
moveToState
addFragment
removeFragment
findFragmentById
findFragmentByTag
enqueueAction
allocBackStackIndex
setBackStackIndex
popBackStackState
restoreAllState
attachActivity
dispatchConfigurationChanged
dispatchCreateOptionsMenu
dispatchPrepareOptionsMenu
dispatchOptionsItemSelected
at android.support.v4.app.BackStackRecord.run(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.makeInactive(Unknown Source)
attachFragment
execPendingActions
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(Unknown Source)
performPendingDeferredStart
hideFragment
freeBackStackIndex
addBackStackState
dispatchContextItemSelected
dispatchOptionsMenuClosed
transitToStyleIndex
at android.support.v4.app.FragmentStatePagerAdapter.setPrimaryItem(Unknown Source)
finishUpdate
at android.support.v4.view.ViewPager.initViewPager(Unknown Source)
setCurrentItem
setCurrentItemInternal
setCurrentItemInternal
scrollToItem
setPageTransformer
setInternalPageChangeListener
distanceInfluenceForSnapDuration
smoothScrollTo
addNewItem
populate
calculatePageOffsets
infoForChild
recomputeScrollPosition
onPageScrolled
completeScroll
isGutterDrag
determineTargetPage
onSecondaryPointerUp
canScroll
executeKeyEvent
getChildRectInPagerCoordinates
access[=11=]0
access0
at android.support.v4.view.ViewPager.populate(Unknown Source)
requestParentDisallowInterceptTouchEvent
arrowScroll
at android.support.v4.view.ViewPager.run(Unknown Source)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:543)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5111)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
这里是 class
的代码
public class SongDetails implements Parcelable
{
public SongDetails( int _ID, String click_no, String Album, String Artist, String Path, String Time, String song, String sortBy, int albumID,
String audioID )
{
this._ID = _ID;
this.click_no = click_no;
this.Album = Album;
this.Artist = Artist;
this.Path = Path;
this.Time = Time;
this.song = song;
this.sortBy = sortBy;
this.albumID = albumID;
this.audioID = audioID;
}
public SongDetails( Parcel in )
{
this._ID = in.readInt( );
this.Path = in.readString();
this.song = in.readString( );
this.Album = in.readString( );
this.Artist = in.readString( );
this.Time = in.readString( );
this.sortBy = in.readString( );
this.click_no = in.readString( );
this.albumID = Integer.parseInt( in.readString( ) );
this.audioID = in.readString( );
}
@Override
public int describeContents( )
{
return 0;
}
@Override
public void writeToParcel( Parcel dest, int flags )
{
dest.writeInt( _ID );
dest.writeString( Path );
dest.writeString( song );
dest.writeString( Album );
dest.writeString( Artist );
dest.writeString( Time );
dest.writeString( sortBy );
dest.writeString( click_no );
dest.writeString( String.valueOf( albumID ) );
dest.writeString( audioID );
}
public static final Parcelable.Creator < SongDetails > CREATOR = new Parcelable.Creator < SongDetails >( ) {
public SongDetails createFromParcel( Parcel in )
{
return new SongDetails( in );
}
public SongDetails [ ] newArray( int size )
{
return new SongDetails [ size ];
}
};
}
activity 代码,正在读取可打包数据
Bundle bundle = getIntent( ).getExtras( );
if ( bundle != null )
{
if ( GlobalSongList.GetInstance( ).getCheck( ) == 0 )
{
try
{
GlobalSongList.GetInstance( ).setPosition( bundle.getInt( "Data2", 0 ) );
if(bundle.getParcelableArrayList( "Data1" )!=null)
{
ArrayList < SongDetails > list =
bundle.getParcelableArrayList( "Data1" );
GlobalSongList.GetInstance( ).SetNowPlayingList( list );
}
CMDNAME = bundle.getString( IConstant.CMDNAME );
}
catch ( Exception e )
{
// e.printStackTrace( );
}
}
comefrom = bundle.getString( "comefrom" );
isFromRecentAdded = bundle.getBoolean( "fromRecentAdded", false );
click_no = bundle.getString( "click_no_playlist" );
我认为问题在于您在解组 SongDetails
列表时没有设置 class 加载器。
您可以通过以下方式阅读"Data1"
:
if(bundle.getParcelableArrayList( "Data1" )!=null) {
bundle.setClassLoader (SongDetails.class.getClassLoader());
ArrayList < SongDetails > list = bundle.getParcelableArrayList( "Data1" );
// Rest of your code
}
我不知道为什么会这样,我无法重现它。 它在控制台中。
我真的很抱歉只输入代码和日志猫,但我什至无法阅读logcat,我之前没有遇到过这样的问题,我什至不知道在哪里首先。 任何帮助将不胜感激。
这是日志猫,
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: bitsie.playmee.musicplayer.free.classes.SongDetails
at android.os.Parcel.readParcelableCreator(Parcel.java:2147)
at android.os.Parcel.readParcelable(Parcel.java:2097)
at android.os.Parcel.readValue(Parcel.java:2013)
at android.os.Parcel.readListInternal(Parcel.java:2343)
at android.os.Parcel.readArrayList(Parcel.java:1703)
at android.os.Parcel.readValue(Parcel.java:2034)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2314)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:1273)
at android.support.v4.app.FragmentManagerImpl.throwException(Unknown Source)
beginTransaction
putFragment
getFragment
saveFragmentInstanceState
dump
makeOpenCloseAnimation
makeFadeAnimation
loadAnimation
moveToState
moveToState
moveToState
addFragment
removeFragment
findFragmentById
findFragmentByTag
enqueueAction
allocBackStackIndex
setBackStackIndex
popBackStackState
restoreAllState
attachActivity
dispatchConfigurationChanged
dispatchCreateOptionsMenu
dispatchPrepareOptionsMenu
dispatchOptionsItemSelected
at android.support.v4.app.FragmentManagerImpl.throwException(Unknown Source)
beginTransaction
putFragment
getFragment
saveFragmentInstanceState
dump
makeOpenCloseAnimation
makeFadeAnimation
loadAnimation
moveToState
moveToState
moveToState
addFragment
removeFragment
findFragmentById
findFragmentByTag
enqueueAction
allocBackStackIndex
setBackStackIndex
popBackStackState
restoreAllState
attachActivity
dispatchConfigurationChanged
dispatchCreateOptionsMenu
dispatchPrepareOptionsMenu
dispatchOptionsItemSelected
at android.support.v4.app.BackStackRecord.run(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.makeInactive(Unknown Source)
attachFragment
execPendingActions
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(Unknown Source)
performPendingDeferredStart
hideFragment
freeBackStackIndex
addBackStackState
dispatchContextItemSelected
dispatchOptionsMenuClosed
transitToStyleIndex
at android.support.v4.app.FragmentStatePagerAdapter.setPrimaryItem(Unknown Source)
finishUpdate
at android.support.v4.view.ViewPager.initViewPager(Unknown Source)
setCurrentItem
setCurrentItemInternal
setCurrentItemInternal
scrollToItem
setPageTransformer
setInternalPageChangeListener
distanceInfluenceForSnapDuration
smoothScrollTo
addNewItem
populate
calculatePageOffsets
infoForChild
recomputeScrollPosition
onPageScrolled
completeScroll
isGutterDrag
determineTargetPage
onSecondaryPointerUp
canScroll
executeKeyEvent
getChildRectInPagerCoordinates
access[=11=]0
access0
at android.support.v4.view.ViewPager.populate(Unknown Source)
requestParentDisallowInterceptTouchEvent
arrowScroll
at android.support.v4.view.ViewPager.run(Unknown Source)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:543)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5111)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
这里是 class
的代码public class SongDetails implements Parcelable
{
public SongDetails( int _ID, String click_no, String Album, String Artist, String Path, String Time, String song, String sortBy, int albumID,
String audioID )
{
this._ID = _ID;
this.click_no = click_no;
this.Album = Album;
this.Artist = Artist;
this.Path = Path;
this.Time = Time;
this.song = song;
this.sortBy = sortBy;
this.albumID = albumID;
this.audioID = audioID;
}
public SongDetails( Parcel in )
{
this._ID = in.readInt( );
this.Path = in.readString();
this.song = in.readString( );
this.Album = in.readString( );
this.Artist = in.readString( );
this.Time = in.readString( );
this.sortBy = in.readString( );
this.click_no = in.readString( );
this.albumID = Integer.parseInt( in.readString( ) );
this.audioID = in.readString( );
}
@Override
public int describeContents( )
{
return 0;
}
@Override
public void writeToParcel( Parcel dest, int flags )
{
dest.writeInt( _ID );
dest.writeString( Path );
dest.writeString( song );
dest.writeString( Album );
dest.writeString( Artist );
dest.writeString( Time );
dest.writeString( sortBy );
dest.writeString( click_no );
dest.writeString( String.valueOf( albumID ) );
dest.writeString( audioID );
}
public static final Parcelable.Creator < SongDetails > CREATOR = new Parcelable.Creator < SongDetails >( ) {
public SongDetails createFromParcel( Parcel in )
{
return new SongDetails( in );
}
public SongDetails [ ] newArray( int size )
{
return new SongDetails [ size ];
}
};
}
activity 代码,正在读取可打包数据
Bundle bundle = getIntent( ).getExtras( );
if ( bundle != null )
{
if ( GlobalSongList.GetInstance( ).getCheck( ) == 0 )
{
try
{
GlobalSongList.GetInstance( ).setPosition( bundle.getInt( "Data2", 0 ) );
if(bundle.getParcelableArrayList( "Data1" )!=null)
{
ArrayList < SongDetails > list =
bundle.getParcelableArrayList( "Data1" );
GlobalSongList.GetInstance( ).SetNowPlayingList( list );
}
CMDNAME = bundle.getString( IConstant.CMDNAME );
}
catch ( Exception e )
{
// e.printStackTrace( );
}
}
comefrom = bundle.getString( "comefrom" );
isFromRecentAdded = bundle.getBoolean( "fromRecentAdded", false );
click_no = bundle.getString( "click_no_playlist" );
我认为问题在于您在解组 SongDetails
列表时没有设置 class 加载器。
您可以通过以下方式阅读"Data1"
:
if(bundle.getParcelableArrayList( "Data1" )!=null) {
bundle.setClassLoader (SongDetails.class.getClassLoader());
ArrayList < SongDetails > list = bundle.getParcelableArrayList( "Data1" );
// Rest of your code
}