RuntimeException(Chromecast) [英] RuntimeException (Chromecast)

查看:122
本文介绍了RuntimeException(Chromecast)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试配置Chromecast,但出现RuntimeException异常,但原因不多。以下是Fabric中的日志:


致命异常:java.lang.RuntimeException:无法启动活动
ComponentInfo {... .activity.TVActivityPhone}:
java.lang.RuntimeException:
com.google.android.gms.dynamite.DynamiteModule $ zza:远程加载
失败。找不到本地备用。 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)的
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2747)的
android.app.ActivityThread.access的
$ 900(ActivityThread.java:187)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1584)
在android.os.Handler.dispatchMessage(Handler.java:111)
在android.os.Looper.loop(Looper.java:194)
在android.app.ActivityThread.main(ActivityThread.java:5877)
在java.lang.reflect.Method.invoke (Method.java)java.lang.reflect.Method.invoke上的
(Method.java:372)com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1020 )com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)中的
,由java.lang.RuntimeException引起:
com.google.android.gms.dynamite.DynamiteModule $ zza:远程加载
失败。找不到本地备用。


这是我的代码:

  protected void configureCast(){
mCastContext = CastContext.getSharedInstance(this); //这里是RuntimeException
if(mCastContext!= null)mCastSession = mCastContext.getSessionManager()。getCurrentCastSession();
mSessionManagerListener = new CastSessionManagerListener(this);
mSessionManagerListener.setCastConnectionListener(mCastConnectionListener);
}

在这里是build.gradle:

 编译'com.google.android.gms:play-services-gcm:10.2.0'
编译'com.google.android.gms:play- services-analytics:10.2.0'
编译'com.google.android.gms:play-services-location:10.2.0'
编译'com.google.android.gms:play-services- cast-framework:10.2.0'

有帮助吗?

解决方案

首先,它与

  • 安装11.3.02(480 -161239932)版本的Android设备上的Google Play服务( apkmirror链接)。



    adb install -r com.google.android.gms_11.3.02_(480-161239932)-11302480_minAPI23(x86,x86_64)(nodpi)_apkmirror.com.apk


  • 访问Google Cast SDK时,打开的应用程序和观察器应用程序崩溃。






  • 崩溃的第二次出现



    我认为我已通过更新Google Play服务,但几周后沉默之后,我收到了通知,通知您再次出现具有相同堆栈跟踪的崩溃。



    经过一番调查(再过几天),我能够重现该问题。这是一个令人难过的消息-我无法对这次崩溃:sad_face:做任何事情,或者至少我还没有找到优雅的解决方案。



    好消息是崩溃再次浮出水面外观非常罕见(每月约有1-2次崩溃)。



    Google Play服务自动更新或强制卸载(可能性较小),强制打开的应用程序生效播放服务更新。这是一个无法控制的过程,这意味着Android操作系统可以随时静默安装Google Play服务。 如果用户打开了应用程序,并且在某个时候完成了Google Play服务的安装,则该应用程序将被系统杀死,而用户需要重新打开它。当应用程序被系统杀死时,我们可以看到在日志中,崩溃的堆栈跟踪与第一种情况完全相同。
    很难复制,只发生在我身上几次。
    但是这种情况很可能是因为Google Play服务经常更新。



    尽管有一种方法可以重现此崩溃(现实中可能性较小) -从设备中删除Google Play服务更新 。它产生相同的堆栈跟踪。



    因此,基本上,我们需要开始删除Google Play服务更新,并迅速(我的意思是非常快)打开我们的应用程序。如果成功,则该应用程序将在启动时被系统杀死,因为删除了Google Play服务,系统也将杀死该应用程序。



    这是堆栈跟踪:

     致命异常:main 
    进程:XXX,PID:26149
    java.lang.RuntimeException:无法启动活动ComponentInfo {XXX / XXX.SomeActivity}:android.view.InflateException:二进制XML文件第0行:二进制XML文件第0行:在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2733 )
    在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2819)
    在android.app.ActivityThread.-wrap12(ActivityThread.java)
    在android.app.ActivityThread $ H .handleMessage(ActivityThread.java:1532)
    在android.os.Handler.dispatchMessage(Handler.java:102)
    在android.os.Looper.loop(Looper.java:154)
    在android.app.ActivityThread.main(ActivityThread.java:6321)
    在java.l com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:886)的ang.reflect.Method.invoke(本机方法)
    com.android.internal.os.ZygoteInit的
    .main(ZygoteInit.java:776)
    原因:android.view.InflateException:二进制XML文件行#0:二进制XML文件行#0:错误夸大类片段
    原因:android.view .InflateException:二进制XML文件第0行:错误夸大类片段
    ,原因:java.lang.RuntimeException:com.google.android.gms.dynamite.DynamiteModule $ zzc:未找到可接受的模块。本地版本为0,远程版本为0。com.google.android.gms.internal.zzavl.zzbp上的
    (未知来源)com.google.android.gms.internal.zzavl.zza上的
    (未知来源)com.google.android.gms.cast.framework.CastContext中的
    。< init>(未知来源)com.google.android.gms.cast.framework.CastContext中的
    。 getSharedInstance(未知来源)
    在com.google.android.gms.cast.framework.media.uicontroller.UIMediaController。< init>(未知来源)
    在com.google.android.gms.cast .framework.media.widget.MiniControllerFragment.onCreateView(未知源)
    在android.support.v4.app.Fragment.performCreateView(Fragment.java:2343)
    在android.support.v4.app。 FragmentManagerImpl.ensureInflatedFragmentView(FragmentManager.java:1645)
    在android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1390)
    在android.support.v4.app.FragmentManagerImpl.moveToState( FragmentManager.java:1640)androi的
    d.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1896)
    在android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3673)
    在android.support。 v4.app.FragmentController.onCreateView(FragmentController.java:111)
    在android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:331)
    在android.support.v4.app。 BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
    在android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:65)
    在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java: 777)android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
    android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
    android.view.LayoutInflater .rInflateChildren(LayoutInflater.java:821)
    在android.view.LayoutInflater.inflate(LayoutInflater.java:518)
    在android.view.Layo utInflater.inflate(LayoutInflater.java:426)
    在android.view.LayoutInflater.inflate(LayoutInflater.java:377)
    在android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java: 287)android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
    在XXX.SomeActivity.setContentView(SomeActivity:XXX)
    在XXX.SomeActivity.onCreate (SomeActivity:XXX)android.app.Activity.performCreate(Activity.java:6760)
    android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)






    更新



    有一个 Google Play服务12.0.0版本,它可以解决此问题:


    修复了在设备w上调用CastContext.getSharedInstance()的错误过期的Google Play服务版本导致崩溃。过时的Google Play服务版本仍然会导致该方法失败,因此客户端应检查适当的版本。


    但实际上,即使更新到12.0.0版本我看到很多崩溃。当设备上发生Google Play服务更新时,会发生崩溃。
    要变通解决此问题,我们需要通过检查调用Cast API时是否未引发异常来检查Cast API是否可用。

      fun isCastApiAvailable():布尔值{
    val isCastApiAvailable = isNotTv(context)
    & GoogleApiAvailability.getInstance()。isGooglePlayServicesAvailable(context)== ConnectionResult.SUCCESS
    try {
    CastContext.getSharedInstance(context)
    } catch(e:Exception){
    // track非致命
    返回false
    }
    返回isCastApiAvailable
    }

    这样,我们可以防止崩溃。如果在前台运行应用程序时更新了Play服务,则该应用程序可能会被系统杀死并重新启动。另外,与Cast API相关的功能将不可用(Chromecast图标不可见)。
    因此,我们避免这种方式的崩溃,并以非致命人员的身份报告,只是为了了解这种情况的发生频率。


    I try to configure Chromecast but got RuntimeException and don't understant the reason. Here are logs from Fabric:

    Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{... .activity.TVActivityPhone}: java.lang.RuntimeException: com.google.android.gms.dynamite.DynamiteModule$zza: Remote load failed. No local fallback found. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2747) at android.app.ActivityThread.access$900(ActivityThread.java:187) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5877) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) Caused by java.lang.RuntimeException: com.google.android.gms.dynamite.DynamiteModule$zza: Remote load failed. No local fallback found.

    And here is my code:

    protected void configureCast() {
            mCastContext = CastContext.getSharedInstance(this); // here I've got RuntimeException
            if(mCastContext != null) mCastSession = mCastContext.getSessionManager().getCurrentCastSession();
            mSessionManagerListener = new CastSessionManagerListener(this);
            mSessionManagerListener.setCastConnectionListener(mCastConnectionListener);
        }
    

    Here is build.gradle:

        compile 'com.google.android.gms:play-services-gcm:10.2.0'
        compile 'com.google.android.gms:play-services-analytics:10.2.0'
        compile 'com.google.android.gms:play-services-location:10.2.0'
        compile 'com.google.android.gms:play-services-cast-framework:10.2.0'
    

    Any help?

    解决方案

    First of all, it's not related to wrong project configuration as described in Why I get this error when on google map "Failed to load DynamiteLoader: java.lang.ClassNotFoundException: Didn't find class?.


    One day I got a spike (~1300 crash in 1 day) in crashes in Fabric with com.google.android.gms.dynamite.DynamiteModule$zza: Remote load failed. No local fallback, com.google.android.gms.dynamite.DynamiteModule$zzc: No acceptable module found. Local version is 0 and remote version is 0 exceptions.

    It wasn't clear to me from the first look why it happened as I didn't ship any update of the application during that period of time. After deeper investigation (few days in total) I have found that the issue is caused by broken compatibility between Google Play Services version and outdated Google Cast SDK.

    My Android application used 10.2.4 version of Google Cast SDK and this version is not compatible with some Google Play Services versions. I have found that 11.3.02 (480-161239932) version of Google Play Service is not compatible with 10.2.4 Google Cast SDK. There are (for sure) other versions of Google Play Services which are not compatible with Google Cast SDK library, but I found just one and it was enough for testing and further fix.

    Having 11.3.02 (480-161239932) version of Google Play Services installed on the device my application was crashing immediately upon start. Worth noting, that I have found other applications on my device which were crashing immediately upon start and stack trace was the same.

    Fix for the crash

    Fix was simple for me - I had to update Google Play Services from 10.2.4 to 11.4.2, in particular play-services-cast-framework, play-services-ads, firebase-core, firebase-messaging.


    Spikes history in Fabric:

    • September 25 (~400 crashes), first spike
    • September 27 (~200 crashes)
    • September 29 (~140 crashes)
    • October 8 (~1300 crashes)

    After October 8th crash wasn't that critical (~10-20 crashes per day) and no more spikes observed. This means that users updated Google Play Services and application didn't crash anymore on start.

    Once I updated the Google Play Services version and users updated to new version of application - crash disappeared (~1-2 crashes per day).

    Explanation of why this crash occured

    As you may know, Google Play Services are automatically updated in background. This means that one day users can receive update of Google Play Services which is not compatible with Google Cast SDK used in application and application will crash (100%).

    From my experience, it happens for Google Cast SDK, but might be the case with other libraries (no proofs).

    Application crashes when you are calling any method from Google Cast SDK. I have commented different places in my application which rely on Google Cast SDK and application was always crashing.

    Detailed guide

    If someone is curious how to mimic this crash, here's detailed guide.

    • First of all, we need to uninstall existing version of Google Play Services. This can be achieved from "Google Play Services" application info screen
    • Install 11.3.02 (480-161239932) version of Google Play Services on Android device (apkmirror link).

      adb install -r com.google.android.gms_11.3.02_(480-161239932)-11302480_minAPI23(x86,x86_64)(nodpi)_apkmirror.com.apk

    • Open application and observer application crash when Google Cast SDK accessed.

    2nd arrival of the crash

    I thought that I have fixed the crash by update Google Play Services, but few weeks after silence I've got notification that crash with the same stacktrace resurfaced.

    After some investigation (few days again) I was able to reproduce the issue. And here are the sad news - I can do nothing about this crash :sad_face: or at least I didn't find elegant solution yet.

    Good news are that resurfaced crash appearance is very rare (~1-2 crashes per month).

    Google Play Services auto-update or force uninstall (less probable) force stops open application to take effect of Play Services update. This is an uncontrollable process, which means that Android OS can install silently Google Play Services at any time. If the user has application open and Google Play Services installation finishes at some point, an application will be killed by the system and user needs to reopen it. When an application is killed by the system, we can see in logs exact the same stacktrace for the crash as we had for the 1st case. It's hard to reproduce and happened to me only a few times. But this case is more probably as Google Play Services are getting updates quite often.

    Though there's a way to reproduce this crash (less probable in real life) - "removal of Google Play Services updates from device". It produces the same stacktrace.

    So basically, we need to start removal of Google Play Services updates and quickly (I mean really quick) open our application. If we succeed, the application will be killed by the system upon start as Google Play Services were removed and system kills the application.

    And here's the stacktrace:

    FATAL EXCEPTION: main
    Process: XXX, PID: 26149
    java.lang.RuntimeException: Unable to start activity ComponentInfo{XXX/XXX.SomeActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2733)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2819)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1532)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6321)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
     Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
     Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class fragment
     Caused by: java.lang.RuntimeException: com.google.android.gms.dynamite.DynamiteModule$zzc: No acceptable module found. Local version is 0 and remote version is 0.
        at com.google.android.gms.internal.zzavl.zzbp(Unknown Source)
        at com.google.android.gms.internal.zzavl.zza(Unknown Source)
        at com.google.android.gms.cast.framework.CastContext.<init>(Unknown Source)
        at com.google.android.gms.cast.framework.CastContext.getSharedInstance(Unknown Source)
        at com.google.android.gms.cast.framework.media.uicontroller.UIMediaController.<init>(Unknown Source)
        at com.google.android.gms.cast.framework.media.widget.MiniControllerFragment.onCreateView(Unknown Source)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2343)
        at android.support.v4.app.FragmentManagerImpl.ensureInflatedFragmentView(FragmentManager.java:1645)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1390)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1640)
        at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1896)
        at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3673)
        at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
        at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:331)
        at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
        at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:65)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
        at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
        at XXX.SomeActivity.setContentView(SomeActivity:XXX)
        at XXX.SomeActivity.onCreate(SomeActivity:XXX)
        at android.app.Activity.performCreate(Activity.java:6760)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
    


    Update

    There was a Google Play Services 12.0.0 release, which supposes to fix the issue:

    Fixed a bug where calling CastContext.getSharedInstance() on devices with out-of-date versions of Google Play services caused a crash. Outdated Google Play services versions still cause the method to fail, so clients should check for an appropriate version.

    But in fact, even after updating to 12.0.0 version I'm seeing lots of crashes. Crashes occur when there's an update of Google Play Services is happening on the device. To workaround this issue, we need to check if Cast API is available by checking if an Exception is not thrown when we call Cast API.

    fun isCastApiAvailable(): Boolean {
        val isCastApiAvailable = isNotTv(context)
                && GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS
        try {
            CastContext.getSharedInstance(context)
        } catch (e: Exception) {
            // track non-fatal
            return false
        }
        return isCastApiAvailable
    }
    

    This way we prevent the crash. The application might be killed and restarted by the system if Play Services update happens when the application is in the foreground. Alternatively, Cast API related features won't be available (Chromecast icon is not visible). So we avoid the crash this way and report as non-fatals just to have understanding how often this situation happens.

    这篇关于RuntimeException(Chromecast)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆