gpt4 book ai didi

android - 应用内更新在android中抛出错误消息

转载 作者:行者123 更新时间:2023-12-02 12:26:57 28 4
gpt4 key购买 nike

我尝试在我的应用程序之一中实现应用内更新功能。我集成了应用内代码 fragment ,但是当我运行代码时,它会抛出一条错误消息。

代码:

 class MainActivity : AppCompatActivity() {
private val REQUEST_CODE: Int = 123
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initInAppUpdate()
}

private lateinit var appUpdateManager: AppUpdateManager
private lateinit var listener: InstallStateUpdatedListener
private fun initInAppUpdate() {
// Create instance of the IAUs manager.
appUpdateManager = AppUpdateManagerFactory.create(this)

// Add state listener to app update info task.
appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
// If there is an update available, prepare to promote it.
Log.d("TAG","====>${appUpdateInfo.updateAvailability()}")
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {

appUpdateManager.startUpdateFlowForResult(
// Pass the intent that is returned by 'getAppUpdateInfo()'.
appUpdateInfo,
// Or 'AppUpdateType.IMMEDIATE for immediate updates.
AppUpdateType.FLEXIBLE,
// The current activity.
this,
REQUEST_CODE
)
}

// If the process of downloading is finished, start the completion flow.
if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
Log.d("TAG","====> InstallStatus.DOWNLOADED")
}
}
.addOnFailureListener { e ->
Log.d("TAG","====> Failed : ${e.printStackTrace()}")
}

// Create a listener to track downloading state updates.
listener = InstallStateUpdatedListener { state ->
// Update progress indicator, request user to approve app reload, etc.
Log.d("TAG","====> Current State : $state")
}

// At some point before starting an update, register a listener for updates.
appUpdateManager.registerListener(listener)
}

override fun onDestroy() {
super.onDestroy()
// At some point when status updates are no longer needed, unregister the listener.
appUpdateManager.unregisterListener(listener)
}
}

错误:
   com.google.android.play.core.internal.aa: Failed to bind to the service.
at com.google.android.play.core.internal.q.b(Unknown Source:82)
at com.google.android.play.core.internal.q.a(Unknown Source:0)
at com.google.android.play.core.internal.s.a(Unknown Source:4)
at com.google.android.play.core.internal.r.run(Unknown Source:0)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)

最佳答案

您正在测试的应用程序的包名称似乎与您的生产应用程序不同,或者您正在使用调试版本。确保您使用相同的包名称和相同的签名 keystore 。

关于android - 应用内更新在android中抛出错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56325221/

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