How can I test In-app updates in Android?

前端 未结 8 1552
死守一世寂寞
死守一世寂寞 2020-12-14 16:05

Recently, Google introduced \'in-app updates\' in Google I/O 2019.

So I am trying to use it.

val appUpdateManager = AppUpdateManagerFactory.create(th         


        
相关标签:
8条回答
  • 2020-12-14 16:10

    Testing using Internal App Sharing

    The right way to test in-app update is to use Internal App Sharing (not to be confused with Internal Testing Track).

    1. First setup your Internal App Sharing with the help of these instructions. Unlike Internal Testing Track, Internal App Sharing makes the app available immediately. So there is no waiting time.
    2. Opt-in to app signing by Google Play. This will allow google play to sign the apk generated for the device from the app bundle you provide. Details here.
    3. Build your app bundle. Through command line, it is simply ./gradlew bundleRelease or ./gradlew bundle<variant>.
    4. Go to https://play.google.com/apps/publish/internalappsharing/ and upload the generated aab file which is under app/build/outputs/bundle/<variant>/. Give a decent name that includes version code.
    5. This will provide a link to copy. Use it to install this bundle to your device.
    6. Bump the version code in your app build.gradle and build another bundle. Note: Version code is integer, that's what is to be incremented. Version name is different and it doesn't matter for this.
    7. Similarly upload this new bundle to Internal App Sharing. Name it with the version code.
    8. This will provide another link. Open the link and this opens google play and you should see "Update" option. Don't click on Update!
    9. Open your app and now you should see in-app update prompt.

    If you don't see the prompt and if you had followed these steps exactly, most likely, there is an issue with your code. Add some logging to see what is happening in your code.

    In our testing, the following did NOT help to test in-app updates (which were suggested elsewhere):

    • Re-uploading the same bundle/apk without bumping up the version code
    • Decreasing version code to be lower than the published version

    Testing using Alpha (closed track)

    Once testing through internal app sharing is successful, I still found some trouble testing in-app update through published versions. After some trials, I was able to successfully test through Alpha track. I'm adding the steps here (I'm assuming you're familiar with Google Play console's Alpha closed track and adding yourself as alpha tester list):

    1. Install current version of the app through Google Play. This can be from production track or alpha or beta track. This version should already have in-app update feature implemented as this is the version that is expected to show in-app update prompt.
    2. Ensure that Automatic Update is disabled just for your app. You can do this through menu item of your app's store listing on Google Play app. We disable automatic update because, we really want to update the app through in-app update instead of Google Play updating the app when your device is charging.
    3. Publish a new version (with version code incremented, changing version name won't matter) to Alpha track.
    4. Nowadays, it takes a while before the published version shows up in Google Play. You may have to wait for several hours.
    5. Once it shows up in Google Play store, you may eagerly try opening your app. You'll be lucky if in-app update prompt shows up. Most likely it won't. In-app update may not show up even if you kept on waiting for several more hours and kept restarting your app. By following the remaining steps I didn't have to wait.
    6. Close your app completely.
    7. Close Google Play app completely.
    8. Clear Google Play app cache. I found that storage need not to be cleared, just the cache.
    9. Open Google Play and go to My Apps & Games from navigation pane.
    10. Now Google Play will search for the updates. Your app update should show up. Do NOT update here, of course.
    11. Open your app. In-app update prompt should appear. If not, test your in-app update with internal app sharing (steps in previous section) and ensure there is no problem with your implementation.

    I guess similar process should work for Beta (open track) and production tracks as well.

    Even after the update is available through Google Play, for the end-users to see in-app update, I think it may take quite some time (days!). Google Play has its own confusing ways. Good luck.

    0 讨论(0)
  • 2020-12-14 16:14

    I don't know if by this time you already got it down, but after some time testing I figured out that decreasing the versionName is what I needed to do to be able to test it properly, before I'd tested only decreasing the versionCode... I think that the API should be able to handle whenever the versionName or versionCode are out of date, but apparently it doesn't.

    0 讨论(0)
  • 2020-12-14 16:20

    Take a look at documentation of FakeAppUpdateManager

    or try below pre-defined method will help you to test app update available or not.

    FakeAppUpdateManager fakeAppUpdateManager = new FakeAppUpdateManager(this);
            fakeAppUpdateManager.setUpdateAvailable(1); // add app version code greater than current version.
            fakeAppUpdateManager.getAppUpdateInfo().addOnSuccessListener(new OnSuccessListener<AppUpdateInfo>() {
                @Override
                public void onSuccess(AppUpdateInfo appUpdateInfo) {
                    if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
                            && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
                        System.out.println("checkForAppUpdateAvailability");
                    }
                }
            });
    
    0 讨论(0)
  • 2020-12-14 16:23

    Hmm... I found the solution. It is not the same as the demo on the Google I/O 2019 - Developer Keynotes.

    I published the signed release apk into the internal developer version. And it works fine.

    Or you can publish it on the "Alpha/Beta close test publish".

    0 讨论(0)
  • 2020-12-14 16:26

    For me, the last step of the Troubleshoot section in the docs made it work!

    Basically, after you change the version of the app (version name and code), do this:

    Make sure the account is eligible and the Google Play cache is up to date. To do so, while logged into the Google Play Store account on the test device, proceed as follows:
    Make sure you completely close the Google Play Store App.
    Open the Google Play Store app and go to the My Apps & Games tab.
    If the app you are testing doesn’t appear with an available update, check that you’ve properly set up your testing tracks.

    0 讨论(0)
  • 2020-12-14 16:30

    Alternatively you can use this class as a UNIT test for simulation of in-app updates

    FakeAppUpdateManager

    This has some pre-defined methods.

    0 讨论(0)
提交回复
热议问题