如果重试,则inappupdate android时java.lang.reflect.InvocationTargetException

编程入门 行业动态 更新时间:2024-10-25 03:25:54
本文介绍了如果重试,则inappupdate android时java.lang.reflect.InvocationTargetException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

重现此错误的步骤:

  • 点击更新按钮&因为它是AppUpdateType.FLEXIBLE,所以它会打开更新应用程序对话框.
  • 点击No, thanks
  • 再次尝试更新.应用程序崩溃并出现以下错误:
  • Click update button & it opens update app dialog since it's AppUpdateType.FLEXIBLE.
  • Click No, thanks
  • Try update again. App crashes with following error:
  • 在下一行通过inappupdate更新应用程序时遇到此异常.

    I'm getting this exception while updating the app via inappupdate on following line.

    appUpdateManager?.startUpdateFlowForResult(it, AppUpdateType.FLEXIBLE, activity, REQUEST_CODE_FLEXI_UPDATE) //it == AppUpdateInfo object

    Stacktrace:

    Stacktrace:

    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408) Caused by: android.content.IntentSender$SendIntentException at android.app.Activity.startIntentSenderForResultInner(Activity.java:4878) at android.app.Activity.startIntentSenderForResult(Activity.java:4847) at androidx.fragment.app.FragmentActivity.startIntentSenderForResult(FragmentActivity.java:796) at android.app.Activity.startIntentSenderForResult(Activity.java:4814) at androidx.fragment.app.FragmentActivity.startIntentSenderForResult(FragmentActivity.java:781) at com.google.android.play.core.appupdate.b.startUpdateFlowForResult(Unknown Source:22) at newProfile.NewProfileFragment.startForInAppUpdate(NewProfileFragment.kt:752) at newProfile.NewProfileFragment.access$startForInAppUpdate(NewProfileFragment.kt:60) at newProfile.NewProfileFragment$setupAppUpdate$3.onClick(NewProfileFragment.kt:682) at android.view.View.performClick(View.java:6935) at android.widget.TextView.performClick(TextView.java:12752) at android.view.View$PerformClick.run(View.java:26214) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164)

    详细信息:

    Android版本:8.0 电话:三星J7

    Android version: 8.0 Phone: Samsung J7

    更新

    根据文档,startUpdateFlowForResult仅应调用一次AppUpdateInfo实例.要再次调用,必须创建AppUpdateInfo实例.

    As per documentation, startUpdateFlowForResult should only called for once AppUpdateInfo instance. For calling again, you must create AppUpdateInfo instance.

    但是由于其实例取决于以下条件,因此如何确保在调用startUpdateFlowForResult

    but since its instance depends on below condition, how to make sure its instance newly gets created before calling startUpdateFlowForResult

    appUpdateManager?.appUpdateInfo?.addOnSuccessListener { if (it.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && it.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) { appUpdateInfo = it updateAvailable.value = true } else { updateAvailable.value = false } }

    也无法获取正在下载的应用的进度值,但在文档中找不到该值.就我而言,onActivityResult不断调用,但是哪个键提供进度值?

    Also how to get progress value of app being downloaded, couldn't find it in documentation. In my case, onActivityResult keeps calling but which key gives progress value?

    还面临着另一个用例不同的问题:跳过安装后inappupdate不可用

    Also facing another issue with different use case: inappupdate not available after skipping installation

    推荐答案

    问题是您试图使用相同的AppUpdateInfo两次触发startUpdateFlowForResult.

    The problem is that you are trying to trigger startUpdateFlowForResult with the same AppUpdateInfo twice.

    按照@Slaw的建议,在更新失败或取消后,您需要再次执行appUpdateManager.appUpdateInfo.addOnSuccessListener才能使另一个AppUpdateInfo实例再次调用startUpdateFlowForResult

    As @Slaw suggested, after a failed or canceled update you need to do appUpdateManager.appUpdateInfo.addOnSuccessListener again in order to have another instance of AppUpdateInfo to make second call to startUpdateFlowForResult

    更多推荐

    如果重试,则inappupdate android时java.lang.reflect.InvocationTargetException

    本文发布于:2023-10-28 23:38:26,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1538100.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:重试   android   inappupdate   java   reflect

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!