20

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")
    }
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
gautam
  • 1,701
  • 2
  • 17
  • 33

12 Answers12

19

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.

Johan Ferreira
  • 515
  • 4
  • 15
  • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](https://meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted](https://stackoverflow.com/help/deleted-answers). – ChrisMM Dec 23 '19 at 14:19
  • @ChrisMM Thanks for the recommendation, I have updated the answer accordingly. – Johan Ferreira Dec 26 '19 at 10:09
  • 1
    Thanks, this solution worked for me. What I want add is after you add new update on google play, make sure to be patient and wait some time (IDK how much exactly, for me it took 5 min) until google play api will start sending info about new update to older app versions. – Tomas Maksimavicius Jan 21 '21 at 08:00
  • 1
    documentation changed, so correct link is https://developer.android.com/guide/playcore/in-app-updates/test – om252345 Sep 27 '21 at 06:35
  • Thanks @om252345, I have updated my link in the answer – Johan Ferreira Sep 27 '21 at 12:00
13

As of today, in-app-update testing can not be done for a debug build. You don't need to put your apk to PlayStore to test also. The best way to test in-app-update is by using internal-app-sharing.

If you follow the below steps one-by-one, you'll be able to test successfully.

  1. To test the app, a tester has to first enable Internal-App-Sharing in PlayStore, follow this link for the same, How to Enable Internal App Sharing for Android?
  2. If you're brave enough to understand the official documents, then simply follow this link to set-up in-app-update testing in your device, https://developer.android.com/guide/playcore/in-app-updates#internal-app-sharing

Here, I'll be writing the same in easy words.

Once you're done with setting up internal-app-sharing in Play-Store, make sure that you have to upload 2 apks to internal-app-sharing on Play-Console and hence generate 2 links. Both apks will be signed using the same signing-key (need not be the same as the one you use to sign for production, any dummy signing-key would work).

  1. First you upload an apk with in-app-update implementation with lower VersionCode (say, 100) to internal-app-sharing on play console.

To know, How to upload apk to internal-app-sharing on Play-Console, follow this lisk, https://support.google.com/googleplay/android-developer/answer/9844679?visit_id=637437125318137239-1277036129&rd=1

NOTE: make sure, you have uninstalled any preinstalled app with the same package-name in your device.

  1. Now you copy the link of the app you uploaded to internal-app-sharing on the play console and use this link to install the app on your device.

NOTE: Before installing, make sure the email-id you're using on play-store has been added in the mail-list on internal-app-sharing on play-console.

  1. Now, once you've installed the app using the link. Now, you need to again create a new signed apk with higher VersionCode (say, 101). And upload this apk to internal-app-sharing.

  2. Now, copy the link with higher VersionCode from internal-app-sharing. Click on this link on your device, it will take you to play-store but this time, update button will be enabled rather than install button as app is already installed in your device with lower VersionCode.

  3. You don't have to click the update button on PlayStore. You just have to click the link and hence open the screen on PlayStore. Now close PlayStore app.

  4. Now, you can launch the already installed app from your device.

If your implementation of in-app-update is fine, launching the app would appear the dialog from PlayStore for update.

Lastly, don't forget to upvote if it helps you in any way. Keep Coding!

Abhishek Kumar
  • 4,532
  • 5
  • 31
  • 53
  • 1
    One Point which work and was not mentioned on Documented. point 6, Thanks for the Help – Khalid Saeed Feb 10 '21 at 12:02
  • I've followed the steps and finally while debugging using the link from internal app sharing, its redirected to playstore with my app opened but Install button is missing in it! My app is supported only in US. I'm trying out from a different country. Could that be the reason? Kindly clarify, Thanks. – Divya Jul 01 '21 at 12:54
  • @Abhishek I'm using flexible update but the google play ui covers the full screen same behaviour as Immediate type update. I'm using the dependency `'com.google.android.play:app-update-ktx:2.0.0'` could you please help me with this? – Kamal Nayan Jun 07 '22 at 13:42
8

I had the similar issue of having UPDATE_NOT_AVAILABLE. After hours of researching, here is how i solved:

  1. use Google play store to install a version of the testing app (I used internal test track rollout)

  2. rollout another version with higher VERSION CODE on Play Console (the same internal test track)

  3. close both testing app and Google play store (not just back to home, use recent key and swipe them off)

  4. open the Google play store and ensure that testing app has an update available (you can check it under "My Apps & Game" > Installed)

  5. now open the testing app and check for UPDATE_AVAILABLE

This works for me almost immediately after rollout

wMaN
  • 309
  • 4
  • 10
7

Basic Requirements for Manual Testing

In order to manually perform the full update flow on the test device, you should have at least two versions of the app with the different version number: a source version and a target version.

  • The source version with the higher version number should be published at Google Play, this is the version which will be identified by Google Play as an available update. The target version with the lower version number and integrated IAUs(In-App Updates) feature should be installed on your device, this is the version which will be updated. The thing is, when the app requests Google Play to check for available updates, it compares the version number of the installed app with the version number of the last available build-in Google Play. So the IAUs feature will be triggered only in case if the version number in Google Play is higher than actual version of the app on the device.
  • Both the source and the target versions need to have the same package name and should be signed with the same release certificate.
  • Android 5.0 (API level 21) or higher.
  • Play Core library 1.5.0 or higher.

Update is Not Available ERROR

First of all, please double-check the requirements mentioned above. If you successfully complete above listed steps in compliance with all requirements and still getting the error then please pay attention to the following trick. The most likely reason is that the Google Play app does not know about the update yet due to the internal caching mechanism. To make sure you have the cache fresh when testing manually you can refresh the cached version by going to the My Apps & Games screen in the Google Play app. Other, alternative, you can simply clear the cache of the Google Play app in the settings. Note that this is just an issue for testing and does not affect end users since the cache is updated daily anyway.

Note - App Bundle is not mandatory for IAUs.

Arpit J.
  • 1,108
  • 12
  • 20
  • Do I need to upload lower version APK to play store and then download it to test?@Arpit – Maulik Dodia Sep 24 '19 at 10:21
  • @MaulikDodia The higher version APK should be published to Google Play, then install the lower version APK with IAU feature to your device. So the IAUs feature will be triggered only in case if the version number in Google Play is higher than the actual version of the app on the device. – Arpit J. Sep 24 '19 at 12:34
  • 1
    I did the same. But no luck. I'm always getting `UPDATE_NOT_AVAILABLE` on `addOnSuccessListener`. Can you help me out? Can you please check my comment on @Oleg answer?@Arpit – Maulik Dodia Sep 24 '19 at 12:54
  • getting same issue, everything same as in app update code but unfortunately getting UPDATE_NOT_AVAILABLE even i installed lowerversion of app – Anuj Vaish Aug 13 '20 at 07:01
4

I installed my app from Google Play. Then I removed it and intalled the signed apk with lower versionCode.

"In-app updates are available only to user accounts that own the app. So, make sure the account you’re using has downloaded your app from Google Play at least once before using the account to test in-app updates." developer.android.com/guide/app-bundle/in-app-updates

Oleg
  • 97
  • 6
  • Are you using Android App Bundle or Apk ? . After installing apk with lower i am getting "This App was not installed by google with no update" – gautam Jul 12 '19 at 21:15
  • 1
    Apk. This works for me: 1. Install my application from Google Play. 2. Remove this application from my smartphone. 3. Install signed apk with lower version code. – Oleg Jul 14 '19 at 12:13
  • **"In-app updates are available only to user accounts that own the app"** - What exactly it means? I have x email id which owns my app in play store and I have y email id, in some other device. I'm installing lower version signed APK (Not From Play Store) in y email id device. I'm not getting Update dialog. Do I need to upload lower version APK to play store? Thanks in advance@Oleg – Maulik Dodia Sep 24 '19 at 10:25
  • Try to install your app from Google Play in your y-email device first. Then remove your app and install apk directly (not from Google Play) – Oleg Sep 25 '19 at 11:18
3

As Arpit J. suggested basic main requirements to test the app, if still you are not able to successfully test the app, I would like to add one more last step that would help you to quickly test the app.

Go to play store app info from settings as shown in image, and do clear data as show in attached screenshots. The steps to go to play store app info may vary device by device.

enter image description here

enter image description here

enter image description here

enter image description here

Smeet
  • 4,036
  • 1
  • 36
  • 47
2

Also there is FakeAppUpdateManager that was created for such purposes. You can use it.

  • Thanks for the help still can't able to show UI from it , its written in doc "This implementation is completely self-contained in the library and does not interact with the Play Store. For this reason no UI is being shown and no update is really performed" – gautam May 14 '19 at 16:58
2

First, you'd have to publish your app to Google Play. Make sure that:

  1. The version code you published is higher than the one you're going to test the updates with, because if not, then it wouldn't recognize it as an update. Then let the Google Play refresh its cache for quite some time (in my case, I've waited for 12 hours before I was able to make it work for the first time).
  2. You've signed both apks with the same signature.

If you want to have a working demo app, I've uploaded a git repository with a lower version code than the one that I've published in Google Play.

Working in-app updates UI

kevintresuelo
  • 166
  • 11
  • I tried your GitHub project but it throws AppUpdateService : Failed to bind to the service error. – Magesh Pandian May 27 '19 at 11:55
  • Oh. That's because you haven't signed the app with my keys. The repo is just for the working demo app source code, signing keys are not published. Nonetheless, I've already uploaded a signed demo apk to the repo that's ready to install. Kindly check it out. – kevintresuelo May 28 '19 at 03:17
  • Thanks for the reply. if I am trying with my project can able to check in debug build or only signed apk it works? – Magesh Pandian May 28 '19 at 04:52
  • If you're trying it with your project, you should probably try to implement it in your own, with your own app signed and published on Google Play. Publishing through the alpha or beta testing channels can help you with that so it doesn't affect your production app. Only the signed apk will work for the demo, as the Play Core library needs a signed apk. Unfortunately, due to security issues, I won't be able to share the keys I used to sign this app. – kevintresuelo May 28 '19 at 05:00
  • Okay But during development how we check with debug build? – Magesh Pandian May 28 '19 at 06:26
  • You should [sign your debug apk](https://stackoverflow.com/a/38626460/3686003) with the same signature you used in your Play Store version. – kevintresuelo May 28 '19 at 09:26
  • 1
    You can test your implementation with debug build but Update flow screen will not open with startUpdateFlowForResult. – ViramP May 30 '19 at 11:59
  • 1
    @kevintresuelo Tried your apk from github link but still not showing any update . – gautam Jun 15 '19 at 11:13
  • 3
    What about the app that has opted for Google Signing-In? We use upload key to sign and upload APK but Google Play uses its own signing key unique to our app for distribution. We do not have access to that signing key. – nitinkumarp Jun 24 '19 at 06:57
  • I'm facing the same issue, and after double checking everything else, it might be because I opted in for Google Signing-In. @nitinkumarp did you manage to work around it? – Filippo Vigani Jan 15 '20 at 11:35
1

Finally resolved this by removing the app from Play Store -> My apps & games -> Library.

  • You must install release application with same keystore that you used for previous version.

This happens when you have previously installed the same app with higher version code on your device or any device which shares the same gmail address in Play Store. Hope this helps.

Vikash Bijarniya
  • 404
  • 4
  • 10
1

When Internal app sharing dont work

Internal App Sharing is not working on a real device. I was testing several hours and always got the latest version of Internal Test and not the one of Interal App Sharing that was what I expected.

The solution is to use an emulator with Play Store.

I describe the step by step:

  1. Create Virtual Device with Google Play greater than or equal to API Level 21 5.0.
  2. Open the emulator and log in with the google account that is in the list of internal testers.
  3. Build the 2 APKs with different versions. Each one with the same versionCode and versionName temporarily to go checking when performing the installations. For example:

APK 1: versionCode and versionName: 100

APK 2: versionCode and versionName: 101

  1. Upload APK 1 to internalappsharing with versionCode and versionName 100

  2. Copy and paste the shared link of APK 1 into Keep Notes web app.

  3. Install APK 1 with versionCode 100 using the link from the emulator Keep Notes application.
  4. The most important thing: Check that the installed app has versionName 100.
  5. If we open APK 1 at this point, no update will be available until we upload APK 2 with a larger version.
  6. Upload APK 2 with code 101 to internalappsharing
  7. Copy and paste the APK 2 link into Keep Notes web app.
  8. DO NOT install APK 2 from the link. Just enter APK 2 link to check that the Play Store describes the existence of an update.
  9. Open the app installed on the emulator with APK 1 and install the update in-app.

Finally, each time they enter a link with a version code greater than the last installed from the emulator they will see the existence of a new update, which should be installed within the app and not from the Play Store.

enter image description here


It is worth mentioning that Logcat is compatible with Internal App Sharing.

GL

Source

Braian Coronel
  • 22,105
  • 4
  • 57
  • 62
0

For the first question, they are saying that you need to do a release build of the app, using your release keystore. Then, you could attach the resulting .apk file to an e-mail and e-mail it to yourself. Then, check your e-mail on your android device and download the .apk attachment to your downloads, and at the end of the download, Android should ask if you want to install the .apk, say yes (if it doesn't ask, then click on the file in your downloads folder, and then it should ask).

For the second question, the only way I can imagine testing this through the internal testing tracks since you have to interact with the Google Play storefront, but not affect your live published release.

Michael Dougan
  • 1,698
  • 1
  • 9
  • 13
0

You got a wait after publishing, it takes 2 to 6 hours.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62