gpt4 book ai didi

android - YouTube Android Player API 在新的 YouTube 版本中抛出 "BadParcelableException ClassNotFoundException when unmarshalling: asc"

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:57:17 24 4
gpt4 key购买 nike

向 YouTube Android Player API 库工程师提交错误:查看 android-youtube-api 标签

在过去一周半的时间里,我注意到这个奇怪的 BadParcelableException 在我们的应用程序中稳步增加,并将其确定为 YouTube 在 Android 上的新版本。

如果您的应用程序正在播放 youtube 视频,将您的应用程序置于后台,强制停止 Youtube 应用程序,然后再次恢复您的应用程序,则会发生此崩溃。可在 Youtube 版本 12.19.56 上重现崩溃。还在较旧的 YouTube 版本 12.05.21 上进行了测试,并没有发生崩溃。

堆栈跟踪:

main Exception: Unable to start activity ComponentInfo{com.myapp.MainActivity}: 
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: asc
Stack: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.MainActivity}:
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: asc
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by:
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: asc
at android.os.Parcel.readParcelableCreator(Parcel.java:2536)
at android.os.Parcel.readParcelable(Parcel.java:2462)
at android.os.Parcel.readValue(Parcel.java:2365)
at android.os.Parcel.readSparseArrayInternal(Parcel.java:2813)
at android.os.Parcel.readSparseArray(Parcel.java:2068)
at android.os.Parcel.readValue(Parcel.java:2422)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2732)
at android.os.BaseBundle.unparcel(BaseBundle.java:269)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:934)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1208)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:2893)
at android.support.v4.app.FragmentController.dispatchCreate(FragmentController.java:190)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:353)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:85)
at com.myapp.BaseActivity.onCreate(BaseActivity.java:36)
at com.myapp.MainActivity.onCreate(MainActivity.java:190)
at android.app.Activity.performCreate(Activity.java:6682)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619) ... 9 more

Caused by: java.lang.ClassNotFoundException: Didn't find class "asc" on path: DexPathList[[zip file "/data/app/com.myapp-naA-_cCrz-w81rqx98ipcQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-naA-_cCrz-w81rqx98ipcQ==/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 32 more

更多信息:

@Override
public void onCreate(Bundle savedInstanceState) {
...
super.onCreate(savedInstanceState); // Crashing here MainActivity.java:190
...
}

最佳答案

View 状态保存和恢复的问题。 Youtube 应用程序有一个错误和存储 View 状态,其中包含来自 youtube apk 的类 asc 的实例。所以我们的应用程序无法恢复它,因为对这个类一无所知。我的解决方案是通过下一个代码阻止 YouTubePlayerViewYouTubePlayerSupportFragment 中保存 View 状态:

@Override
public void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);

// disable view state saving to prevent saving states from youtube apk which cannot be restored.
View view = getView();
if (view instanceof ViewGroup) {
ViewGroup viewGroup = ((ViewGroup) view);
for (int i = 0; i < viewGroup.getChildCount(); i++) {
viewGroup.getChildAt(i).setSaveFromParentEnabled(false);
}
}
}

此代码应添加到 YouTubePlayerSupportFragment 的子类中。此解决方案不会从 bundle 中删除 youtube 播放器状态。这样youtube player就恢复成功了。

关于android - YouTube Android Player API 在新的 YouTube 版本中抛出 "BadParcelableException ClassNotFoundException when unmarshalling: asc",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44379747/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com