0
votes

I'm facing a wired issue my app keep crash whenever it idle (after hitting lock screen button) but only on API 24 and 23 i have tested it on lollipop and below and it still resume properly

I encounter a documentation about the new battery optimisation system Doze

But from what i understand this screw with Activity life cycle (OnPause, OnResume ...)

PS : I made the test with only a simple YouTube activity with no other components and it still crash

Java Source

public class PlayerActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {

private YouTubePlayer youTubePlayer;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);
    // Initializing YouTube player view
    YouTubePlayerView youTubePlayerView = findViewById(R.id.youtube_player_view);
    youTubePlayerView.initialize(Constants.YOUTUBE_API_KEY, this);
}

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {
    if(null== youTubePlayer) return;
    this.youTubePlayer = youTubePlayer;
    // Start buffering
    if (!wasRestored) {
        youTubePlayer.loadVideo("gsjtg7m1MMM");
    }
}

@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {

}

@Override
protected void onDestroy() {
    super.onDestroy();
    youTubePlayer = null;
}

}

Layout:

FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"

app:layout_behavior="@string/appbar_scrolling_view_behavior"

tools:showIn="@layout/activity_player">

    <com.google.android.youtube.player.YouTubePlayerView
        android:id="@+id/youtube_player_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

09-13 13:03:29.936 21317-21317/info.digibox.replaytv E/Parcel: Class not found when unmarshalling: aps
                                                           java.lang.ClassNotFoundException: aps
                                                               at java.lang.Class.classForName(Native Method)
                                                               at java.lang.Class.forName(Class.java:400)
                                                               at android.os.Parcel.readParcelableCreator(Parcel.java:2517)
                                                               at android.os.Parcel.readParcelable(Parcel.java:2471)
                                                               at android.os.Parcel.readValue(Parcel.java:2374)
                                                               at android.os.Parcel.readSparseArrayInternal(Parcel.java:2808)
                                                               at android.os.Parcel.readSparseArray(Parcel.java:2077)
                                                               at android.os.Parcel.readValue(Parcel.java:2431)
                                                               at android.os.Parcel.readArrayMapInternal(Parcel.java:2727)
                                                               at android.os.BaseBundle.unparcel(BaseBundle.java:269)
                                                               at android.os.Bundle.getSparseParcelableArray(Bundle.java:910)
                                                               at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2262)
                                                               at android.app.Activity.onRestoreInstanceState(Activity.java:1128)
                                                               at android.app.Activity.performRestoreInstanceState(Activity.java:1083)
                                                               at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1182)
                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
                                                               at android.app.ActivityThread.-wrap14(ActivityThread.java)
                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
                                                               at android.os.Handler.dispatchMessage(Handler.java:102)
                                                               at android.os.Looper.loop(Looper.java:154)
                                                               at android.app.ActivityThread.main(ActivityThread.java:6776)
                                                               at java.lang.reflect.Method.invoke(Native Method)
                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
                                                            Caused by: java.lang.ClassNotFoundException: Didn't find class "aps" on path: DexPathList[[zip file "/data/app/info.digibox.replaytv-1/base.apk"],nativeLibraryDirectories=[/data/app/info.digibox.replaytv-1/lib/arm, /data/app/info.digibox.replaytv-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
                                                               at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                               at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
                                                               at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                               at java.lang.Class.classForName(Native Method) 
                                                               at java.lang.Class.forName(Class.java:400) 
                                                               at android.os.Parcel.readParcelableCreator(Parcel.java:2517) 
                                                               at android.os.Parcel.readParcelable(Parcel.java:2471) 
                                                               at android.os.Parcel.readValue(Parcel.java:2374) 
                                                               at android.os.Parcel.readSparseArrayInternal(Parcel.java:2808) 
                                                               at android.os.Parcel.readSparseArray(Parcel.java:2077) 
                                                               at android.os.Parcel.readValue(Parcel.java:2431) 
                                                               at android.os.Parcel.readArrayMapInternal(Parcel.java:2727) 
                                                               at android.os.BaseBundle.unparcel(BaseBundle.java:269) 
                                                               at android.os.Bundle.getSparseParcelableArray(Bundle.java:910) 
                                                               at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2262) 
                                                               at android.app.Activity.onRestoreInstanceState(Activity.java:1128) 
                                                               at android.app.Activity.performRestoreInstanceState(Activity.java:1083) 
                                                               at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1182) 
                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947) 
                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
                                                               at android.app.ActivityThread.-wrap14(ActivityThread.java) 
                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
                                                               at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                               at android.os.Looper.loop(Looper.java:154) 
                                                               at android.app.ActivityThread.main(ActivityThread.java:6776) 
                                                               at java.lang.reflect.Method.invoke(Native Method) 
                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) 
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 

09-13 13:03:29.939 21317-21317/info.digibox.replaytv D/AndroidRuntime: Shutting down VM 09-13 13:03:29.941 21317-21317/info.digibox.replaytv E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{info.digibox.replaytv/info.digibox.replaytv.activities.PlayerActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: aps at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: aps at android.os.Parcel.readParcelableCreator(Parcel.java:2545) at android.os.Parcel.readParcelable(Parcel.java:2471) at android.os.Parcel.readValue(Parcel.java:2374) at android.os.Parcel.readSparseArrayInternal(Parcel.java:2808) at android.os.Parcel.readSparseArray(Parcel.java:2077) at android.os.Parcel.readValue(Parcel.java:2431) at android.os.Parcel.readArrayMapInternal(Parcel.java:2727) at android.os.BaseBundle.unparcel(BaseBundle.java:269) at android.os.Bundle.getSparseParcelableArray(Bundle.java:910) at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2262) at android.app.Activity.onRestoreInstanceState(Activity.java:1128) at android.app.Activity.performRestoreInstanceState(Activity.java:1083) at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1182) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)  at android.app.ActivityThread.-wrap14(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6776)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)  09-13 13:03:29.947 21317-21359/info.digibox.replaytv I/FA: Tag Manager is not found and thus will not be used 09-13 13:03:29.950 21317-21359/info.digibox.replaytv D/FA: Logging event (FE): app_exception(_ae), Bundle[{firebase_event_origin(_o)=crash, timestamp=1505307809942, fatal=1}] 09-13 13:03:29.967 21317-21359/info.digibox.replaytv V/FA: Using measurement service 09-13 13:03:29.967 21317-21359/info.digibox.replaytv V/FA: Connection attempt already in progress 09-13 13:03:30.205 21317-21317/info.digibox.replaytv E/AndroidRuntime: FATAL EXCEPTION: main Process: info.digibox.replaytv, PID: 21317 java.lang.RuntimeException: Unable to start activity ComponentInfo{info.digibox.replaytv/info.digibox.replaytv.activities.PlayerActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: aps at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: aps at android.os.Parcel.readParcelableCreator(Parcel.java:2545) at android.os.Parcel.readParcelable(Parcel.java:2471) at android.os.Parcel.readValue(Parcel.java:2374) at android.os.Parcel.readSparseArrayInternal(Parcel.java:2808) at android.os.Parcel.readSparseArray(Parcel.java:2077) at android.os.Parcel.readValue(Parcel.java:2431) at android.os.Parcel.readArrayMapInternal(Parcel.java:2727) at android.os.BaseBundle.unparcel(BaseBundle.java:269) at android.os.Bundle.getSparseParcelableArray(Bundle.java:910) at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2262) at android.app.Activity.onRestoreInstanceState(Activity.java:1128) at android.app.Activity.performRestoreInstanceState(Activity.java:1083) at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1182) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)  at android.app.ActivityThread.-wrap14(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6776)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)  09-13 13:03:30.218 21317-21422/info.digibox.replaytv I/FirebaseCrash: Sending crashes

Having problem formatring a create a gist here Thanks in advance

1
Please provide a minimal reproducible example with a complete Java stack trace and any code of yours referenced in the stack trace.CommonsWare
I have edited my questionthunder413
Just to confirm, is info.digibox.replaytv your app? Are you on the latest YouTube library?CommonsWare
Yes it's my app package and i'm using the latested Youtube library and i'm also using buildToolsVersion "26.0.1" and targeting 26 with min sdk 19thunder413

1 Answers

1
votes

It's failing to find a class called aps when unbundling a Parcelable. Do a Find in files for "aps" to see if there is any mention to this class in your code.

Also, is it happening in debug or release? If it's release, is it possible that you have Proguard enabled in your build (could also be the case for debug builds, just less common)?

Try not storing the private field YouTubePlayer youTubePlayer:

public class PlayerActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_player);
        // Initializing YouTube player view
        YouTubePlayerView youTubePlayerView = findViewById(R.id.youtube_player_view);
        youTubePlayerView.initialize(Constants.YOUTUBE_API_KEY, this);
    }

    @Override
    public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean wasRestored) {
        if(null== youTubePlayer) return;
        // Start buffering
        if (!wasRestored) {
            youTubePlayer.loadVideo("gsjtg7m1MMM");
        }
    }

    @Override
    public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {

    }
}