I am using In-App Update API
in the application for Update Application while the new version is available in play store.
module gradle
defaultConfig {
applicationId "xxx.xxxxx"
minSdkVersion 21
targetSdkVersion 28
versionCode rootProject.ext.vCode
versionName rootProject.ext.vName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Last upload version(Live in Playstore)
vCode = 5
vName = "1.0.4"
project gradle (downgrade it for the testing)
vCode = 4
vName = "1.0.3"
Downgrade this version for the testing update available or not.
MainActivity.kt
class MainActivity : AppCompatActivity() {
private var appUpdateManager: AppUpdateManager? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
appUpdateManager = AppUpdateManagerFactory.create(this)
}
override fun onResume() {
super.onResume()
checkForVersionUpdate()
}
private fun checkForVersionUpdate() {
appUpdateManager?.appUpdateInfo?.addOnSuccessListener { appUpdateInfo ->
if ((appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS)) {
// If an in-app update is already running, resume the update.
startUpdateFlow(appUpdateInfo)
} else if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(IMMEDIATE)) {
startUpdateFlow(appUpdateInfo)
}
}
}
private fun startUpdateFlow(appUpdateInfo: AppUpdateInfo) {
try {
appUpdateManager?.startUpdateFlowForResult(
appUpdateInfo,
IMMEDIATE,
this,
123)
} catch (e: InvocationTargetException) {
e.printStackTrace()
} catch (e: IntentSender.SendIntentException) {
e.printStackTrace()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == 123) {
if (resultCode != RESULT_OK) {
Log.i("Update failed code:", resultCode.toString())
// If the update is cancelled or fails,
// you can request to start the update again.
} else if(resultCode == RESULT_CANCELED)
checkForVersionUpdate()
}
}
}
I last uploaded build in play store with App Bundle(.aab) and Open Beta.
Tried following ways.
- Sign apk with the same package name.
- Clear Playstore apk cache and storage.
- Download apk from playstore and uninstall it from device. then after downgrade version code and sign apk and install it in device. Still not showing update app dialog.