应用内更新提供InstallException(ERROR_API_NOT_AVAILABLE) [英] In-App Update gives InstallException (ERROR_API_NOT_AVAILABLE)
问题描述
使用以下代码段实现了应用内更新功能:
Implemented in-app update feature, using the following code snippet:
private void showInAppUpdateDialog(boolean isMandatoryUpdate) {
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
|| appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
int appUpdateType = isMandatoryUpdate ? IMMEDIATE : AppUpdateType.FLEXIBLE;
int requestCode = isMandatoryUpdate ? REQUEST_APP_UPDATE_IMMEDIATE : REQUEST_APP_UPDATE_FLEXIBLE;
if (appUpdateInfo.isUpdateTypeAllowed(appUpdateType)) {
// start the app update
try {
appUpdateManager.startUpdateFlowForResult(appUpdateInfo, appUpdateType, targetActivity, requestCode);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
}
}).addOnFailureListener(e -> {
e.printStackTrace();
});
}
我正在具有Android 9的设备上测试应用程序内更新.不过,它仍然给我以下错误消息(ERROR_API_NOT_AVAILABLE):
I am testing in-app update on the device which has Android 9. Still, it is giving me following an error (ERROR_API_NOT_AVAILABLE):
com.google.android.play.core.install.InstallException: Install Error(-3): The API is not available on this device. (https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode#ERROR_API_NOT_AVAILABLE)
at com.google.android.play.core.appupdate.i.a(Unknown Source:24)
at com.google.android.play.core.internal.o.a(Unknown Source:13)
at com.google.android.play.core.internal.j.onTransact(Unknown Source:22)
at android.os.Binder.execTransact(Binder.java:731)
是说,请检查以下链接: https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode#ERROR_API_NOT_AVAILABLE )
It is saying that check the following link: https://developer.android.com/reference/com/google/android/play/core/install/model/InstallErrorCode#ERROR_API_NOT_AVAILABLE)
使用Play核心库版本:1.6.5
Using Play core library version: 1.6.5
最新的核心库版本:
implementation 'com.google.android.play:core:1.7.0'
但是,我不知道为什么说ERROR_API_NOT_AVAILABLE.任何帮助将不胜感激!
However, I am not able to get why it is saying that ERROR_API_NOT_AVAILABLE. Any help would be appreciated!
推荐答案
首先,请检查您是否正在使用最新版本的播放库.
Firstly, please check that you are using the latest version of the play library.
其次,轻描淡写的事实:请检查您要测试的应用具有与Play商店中可用的包名称相同的包名称.
Secondly, understated fact: Please check the app you are testing has the same package name which is available on the play store.
示例:
您在Play商店中有一个应用程序,其程序包名为 com.example.app
,但是您正在测试该应用程序的程序包名为 com.example.app.debug
.您将收到以下错误: ERROR_API_NOT_AVAILABLE
You have an app on the play store with package name com.example.app
but you are testing your app with package name com.example.app.debug
. You will get this error: ERROR_API_NOT_AVAILABLE
注意:测试时,您需要在Play商店上拥有至少一个版本的应用.
Note: You need to have at least one version of your app on the play store when you are testing.
这篇关于应用内更新提供InstallException(ERROR_API_NOT_AVAILABLE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!