Search code examples
androidkotlingoogle-playin-app-updategoogle-play-core

In-App Update API showing UPDATE_NOT_AVAILABLE while testing on debugging device


I am trying to integrate the new In-App Update API but I cannot able to test it's implementation. Seems like my code is fine therefore I read the Troubleshoots and am not able to understand 2 points in this document

Make sure that the app that you are testing is signed with the same signing key as the one available from Google Play.

  1. How can I sign with same signing key in debug mode while installing Apk on Connected device?.

If the app you are testing doesn’t appear with an available update, check that you’ve properly set up your testing tracks.

  1. Is it compulsory to release App in internal testing tracks to test implementation?

Anyway I just want to test on my device and I decremented the version code from the play store version but its showing always UPDATE_NOT_AVAILABLE.

Here is code:-

val appUpdateInfo: Task<AppUpdateInfo> = appUpdateManager.appUpdateInfo
appUpdateInfo.addOnSuccessListener {
    if (it.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && it.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
        appUpdateManager.startUpdateFlowForResult(it, AppUpdateType.FLEXIBLE, this, 2);
    }else{
        toast("Not Available")
    }
}

Solution

  • I struggled with this same problem for a few days before once again going through the documentation thoroughly. Read this section on the official documentation of the in-app updates.

    The link describes the correct testing procedure as follows:

    1. On your test device, make sure you've already installed a version of your app that meets the following requirements:
    • The app was installed using an internal app sharing URL
    • Supports in-app updates
    • Uses a version code that's lower than the updated version of your app
    1. Follow the Play Console instructions on how to share your app internally. Make sure you upload a version of your app that uses a version code that's higher than the one you have already installed on the test device.
    2. On the test device, only click the internal app-sharing link for the updated version of your app. Do not install the app from the Google Play Store page you see after clicking the link.
    3. Open the app from the device's app drawer or home screen. The update should now be available to your app, and you can test your implementation of in-app updates.

    This is also super helpful because you don't have to wait for the app to be published, you can start testing immediately.