appcenter-sdk-android icon indicating copy to clipboard operation
appcenter-sdk-android copied to clipboard

In-app updates fail on MIUI devices with optimizations enabled (AppCenter SDK 4.3.1+)

Open LennonReid opened this issue 1 year ago • 1 comments

Description

The in-app update feature is non-functional when MIUI optimization is enabled in appCenter version 5.0.2, the latest release. However, earlier appCenter version 4.3.1 does allow in-app updates to work properly even with MIUI optimization turned on.

This suggests a regression bug was introduced in appCenter version 5.0.2, causing in-app updates to fail on devices with MIUI optimizations enabled. Asking users to disable MIUI optimizations is not an acceptable workaround, as this would inconvenience users and potentially annoy them. Instead, developers should consider downgrading to the previous stable release, appCenter 4.3.1, as a temporary workaround.

Repro Steps

Please list the steps used to reproduce your issue.

  1. Refer to the Microsoft documentation to configure the AppCenter SDK in an Android app properly: https://learn.microsoft.com/en-us/appcenter/sdk/getting-started/android
  2. Release an app built through AppCenter and install it on a Xiaomi device with MIUI optimization enabled.
  3. Upload a new version increment of the app to AppCenter.
  4. Launch the app on the Xiaomi device and initiate the in-app update flow when prompted.
  5. Check LogCat in Android Studio after in-app update failure. An "INSTALL_FAILED_ABORTED" error related to permissions will be logged, indicating the update was blocked by MIUI optimizations.

Details

  1. Which SDK version are you using?
    • 5.0.2
  2. Which OS version did you experience the issue on?
    • Android 11
  3. What device version did you see this error on? Were you using an emulator or a physical device?
    • Xiaomi11 physical device
  4. What third party libraries are you using?
    • none
  5. Please enable verbose logging for your app using AppCenter.setLogLevel(Log.VERBOSE) before your call to AppCenter.start(...) and include the logs here:

2023-11-13 23:03:49.146 22248-22248 AppCenter               io.ionic.starter                     W  App Center may only be configured once.
2023-11-13 23:03:49.146 22248-22324 AppCenterDistribute     io.ionic.starter                     D  Distribute workflow will be resumed on activity resume event.
2023-11-13 23:03:49.149 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Resetting workflow on entering foreground.
2023-11-13 23:03:49.150 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Resume distribute workflow...
2023-11-13 23:03:49.150 22248-22248 AppCenterDistribute     io.ionic.starter                     I  Get latest release details...
2023-11-13 23:03:49.150 22248-22324 AppCenterAnalytics      io.ionic.starter                     D  onActivityResumed
2023-11-13 23:03:49.150 22248-22324 AppCenterAnalytics      io.ionic.starter                     D  noLogSentForLong=true wasBackgroundForLong=true
2023-11-13 23:03:49.150 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Check if we need to report release installation..
2023-11-13 23:03:49.150 22248-22248 AppCenterDistribute     io.ionic.starter                     D  New release was downloaded but not installed yet, skip reporting.
2023-11-13 23:03:49.151 22248-22324 AppCenter               io.ionic.starter                     D  Storing a log to the Persistence database for log type startSession with flags=1
2023-11-13 23:03:49.153 22248-27400 AppCenterDistribute     io.ionic.starter                     V  Calling https://api.appcenter.ms/v0.1/public/sdk/apps/****************************2e76e499/releases/latest?is_install_page=true&release_hash=9329cae68bca7204a213bea1bb05d59a12fd4d6ebeb2333c5d658fc8cfc9d6e8...
2023-11-13 23:03:49.153 22248-27400 AppCenterDistribute     io.ionic.starter                     V  Headers: {}
2023-11-13 23:03:49.154 22248-27400 CapacitorCookies        io.ionic.starter                     I  Getting cookies at: 'https://api.appcenter.ms/v0.1/public/sdk/apps/8140dfc4-2b47-4990-94f5-ebe12e76e499/releases/latest?is_install_page=true&release_hash=9329cae68bca7204a213bea1bb05d59a12fd4d6ebeb2333c5d658fc8cfc9d6e8'
2023-11-13 23:03:49.156 22248-22324 AppCenter               io.ionic.starter                     D  Stored a log to the Persistence database for log type startSession with databaseId=27
2023-11-13 23:03:49.156 22248-22324 AppCenter               io.ionic.starter                     D  enqueue(group_analytics) pendingLogCount=4
2023-11-13 23:03:49.156 22248-22324 AppCenter               io.ionic.starter                     D  Channel is temporarily disabled, log was saved to disk.
2023-11-13 23:03:50.245 22248-27400 AppCenter               io.ionic.starter                     V  HTTP response status=200 payload={"app_name":"ionic-test","app_display_name":"ionic-test","app_os":"Android","app_icon_url":"https://appcenter-filemanagement-distrib1ede6f06e.azureedge.net/11bbb2e8-5e46-413c-a552-f749667ac274/u3.png?sv=2019-02-02&sr=c&sig=WelcIz1%2FCWDw8JFQ6YO4QdhId2DqecMsNapejvLV8eI%3D&se=2023-11-20T14%3A25%3A02Z&sp=r","release_notes_url":"https://install.appcenter.ms/users/lennonReid/apps/ionic-test/distribution_groups/Public","owner":{"name":"lennonReid","display_name":"Lennon Reid"},"is_external_build":false,"origin":"appcenter","id":8,"version":"6","short_version":"0.0.6","size":4222252,"min_os":"5.1","android_min_api_level":"22","device_family":null,"bundle_identifier":"io.ionic.starter","fingerprint":"e761f77b46ed81853ed56683789d9bf0","uploaded_at":"2023-11-13T14:25:00.455Z","download_url":"https://appcenter-filemanagement-distrib5ede6f06e.azureedge.net/e04a14e6-0e35-456b-b00f-bb29a2efcd31/app-release.apk?sv=2019-02-02&sr=c&sig=z4L1EZmqI%2BKoQ3U1nKaVzbhlC1kkNrEbGJ5JB0X2ToI%3D&se=2023-11-14T14%3A52%3A56Z&sp=r","install_url":"https://appcenter-filemanagement-distrib5ede6f06e.azureedge.net/e04a14e6-0e35-456b-b00f-bb29a2efcd31/app-release.apk?sv=2019-02-02&sr=c&sig=z4L1EZmqI%2BKoQ3U1nKaVzbhlC1kkNrEbGJ5JB0X2ToI%3D&se=2023-11-14T14%3A52%3A56Z&sp=r","mandatory_update":false,"enabled":true,"fileExtension":"apk","is_latest":true,"release_notes":"v0.0.6","can_resign":null,"package_hashes":["138725618e179e2efde5e5fdca8eac481860be2a85a27aadc444f33a23135170"],"destination_type":"group","status":"available","distribution_group_id":"fa643005-9860-4fd4-bee7-18583e42291a","distribution_groups":[{"id":"fa643005-9860-4fd4-bee7-18583e42291a","name":"Public","origin":"appcenter","display_name":"Public","is_public":true}]}
2023-11-13 23:03:50.246 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Stored release hash doesn't match current installation, probably downloaded but not installed yet, keep in store
2023-11-13 23:03:50.246 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Check if latest release is more recent.
2023-11-13 23:03:50.246 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Latest release more recent=true
2023-11-13 23:03:50.246 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Removing download and notification id=2812
2023-11-13 23:03:50.246 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Latest release is more recent.
2023-11-13 23:03:50.246 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Show default update dialog.
2023-11-13 23:03:53.618 22248-22248 AppCenterDistribute     io.ionic.starter                     D  There is no need to request permissions in runtime on Android earlier than 6.0.
2023-11-13 23:03:53.618 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Schedule download...
2023-11-13 23:03:53.619 22248-30103 AppCenterDistribute     io.ionic.starter                     D  Start downloading new release from https://appcenter-filemanagement-distrib5ede6f06e.azureedge.net/e04a14e6-0e35-456b-b00f-bb29a2efcd31/app-release.apk?sv=2019-02-02&sr=c&sig=z4L1EZmqI%2BKoQ3U1nKaVzbhlC1kkNrEbGJ5JB0X2ToI%3D&se=2023-11-14T14%3A52%3A56Z&sp=r
2023-11-13 23:03:53.654 22248-30103 AppCenterDistribute     io.ionic.starter                     D  Start download 0.0.6 (6) update.
2023-11-13 23:03:53.712 24847-30104 DownloadThread          android.process.media                D  in runInternal, Download mId=2813 uri=https://appcenter-filemanagement-distrib5ede6f06e.azureedge.net/e04a14e6-0e35-456b-b00f-bb29a2efcd31/app-release.apk?sv=2019-02-02&sr=c&sig=z4L1EZmqI%2BKoQ3U1nKaVzbhlC1kkNrEbGJ5JB0X2ToI%3D&se=2023-11-14T14%3A52%3A56Z&sp=r
2023-11-13 23:03:59.839 22248-22248 AppCenterDistribute     io.ionic.starter                     V  Receive broadcast action: android.intent.action.DOWNLOAD_COMPLETE
2023-11-13 23:03:59.839 22248-30103 AppCenterDistribute     io.ionic.starter                     D  Check download id=2813
2023-11-13 23:03:59.860 22248-30114 AppCenterDistribute     io.ionic.starter                     D  Download was successful for id=2813
2023-11-13 23:03:59.865 22248-22248 AppCenterDistribute     io.ionic.starter                     I  Start installing new release...
2023-11-13 23:03:59.865 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Stored release details: group id=fa643005-9860-4fd4-bee7-18583e42291a release hash=138725618e179e2efde5e5fdca8eac481860be2a85a27aadc444f33a23135170 release id=8
2023-11-13 23:03:59.865 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Trying to install update via PackageInstaller.
2023-11-13 23:03:59.865 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Register receiver for installing a new release.
2023-11-13 23:03:59.877 22248-22248 AppCenterDistribute     io.ionic.starter                     V  The install session was created. sessionId=1380486471
2023-11-13 23:03:59.921 22248-22248 AppCenterDistribute     io.ionic.starter                     V  Installation progress: 80%. sessionId=1380486471
2023-11-13 23:03:59.921 22248-22248 AppCenterDistribute     io.ionic.starter                     V  Receive broadcast action: com.microsoft.appcenter.action.INSTALL_STATUS
2023-11-13 23:03:59.921 22248-22248 AppCenterDistribute     io.ionic.starter                     V  	android.content.pm.extra.STATUS: -1
2023-11-13 23:03:59.921 22248-22248 AppCenterDistribute     io.ionic.starter                     V  	android.content.pm.extra.SESSION_ID: 1380486471
2023-11-13 23:03:59.921 22248-22248 AppCenterDistribute     io.ionic.starter                     V  	android.intent.extra.INTENT: Intent { act=android.content.pm.action.CONFIRM_INSTALL pkg=com.miui.packageinstaller (has extras) }
2023-11-13 23:03:59.921 22248-22248 AppCenterDistribute     io.ionic.starter                     I  Ask confirmation to install a new release.
2023-11-13 23:03:59.922  1638-2637  ActivityTaskManager     system_server                        I  START u0 {flg=0x30010000 cmp=io.ionic.starter/com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity (has extras)} from uid 10507
2023-11-13 23:03:59.932 22248-22324 AppCenterAnalytics      io.ionic.starter                     D  onActivityPaused
2023-11-13 23:03:59.954 22248-22324 AppCenterAnalytics      io.ionic.starter                     D  onActivityResumed
2023-11-13 23:03:59.954 22248-22324 AppCenterAnalytics      io.ionic.starter                     D  noLogSentForLong=false wasBackgroundForLong=false
2023-11-13 23:03:59.962 32690-32715 AppUpdateXmsfLauncher   com.xiaomi.xmsf                      D  activityResumed intent : Intent { cmp=io.ionic.starter/com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity (has extras) }
2023-11-13 23:03:59.962  2927-2927  RecentsImpl             com.miui.home                        D  mActivityStateObserver com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity
2023-11-13 23:03:59.962  2927-2927  RecentsImpl             com.miui.home                        W  onResumed className=com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity   mIsInAnotherPro=false   isKeyguardLocked=false
2023-11-13 23:03:59.962 24680-30085 VA_ActivityStateHelper  com.miui.voiceassist                 I  activityResumed componentName ComponentInfo{io.ionic.starter/com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity}
2023-11-13 23:03:59.962 22248-22324 AppCenterAnalytics      io.ionic.starter                     D  onActivityPaused
2023-11-13 23:04:00.031  1638-9159  Timeline                system_server                        I  Timeline: Activity_windows_visible id: ActivityRecord{fc6f6a u0 io.ionic.starter/com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity t2865} time:434372906
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     V  The installation has been finished. sessionId=1380486471, success=false
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     V  Receive broadcast action: com.microsoft.appcenter.action.INSTALL_STATUS
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     V  	android.content.pm.extra.STATUS: 3
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     V  	android.content.pm.extra.PACKAGE_NAME: io.ionic.starter
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     V  	android.content.pm.extra.SESSION_ID: 1380486471
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     V  	android.content.pm.extra.LEGACY_STATUS: -115
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     V  	android.content.pm.extra.STATUS_MESSAGE: INSTALL_FAILED_ABORTED: User rejected permissions
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Installation cancelled.
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Complete current updating process.
2023-11-13 23:04:00.035 22248-22248 AppCenterDistribute     io.ionic.starter                     D  Unregister receiver for installing a new release.
2023-11-13 23:04:00.036 22248-22248 AppCenterDistribute     io.ionic.starter                     V  Release installer activity result=0
2023-11-13 23:04:00.036  1638-1800  ActivityTaskManager     system_server                        I  Displayed io.ionic.starter/com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity: +70ms
2023-11-13 23:04:00.045  1638-3110  MIUIInput               system_server                        D  [FoucsChange]: Display  0 FocusedWindow From null(0,0)  to Window{e9c80a4 mode=1 rootTaskId=2865 u0 io.ionic.starter/com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity}(1,1)
2023-11-13 23:04:00.059 32690-32715 AppUpdateXmsfLauncher   com.xiaomi.xmsf                      D  activityResumed intent : Intent { cmp=io.ionic.starter/com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity (has extras) }
2023-11-13 23:04:00.059 24680-30085 VA_ActivityStateHelper  com.miui.voiceassist                 I  activityResumed componentName ComponentInfo{io.ionic.starter/com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity}
2023-11-13 23:04:00.060  2927-2927  RecentsImpl             com.miui.home                        D  mActivityStateObserver com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity
2023-11-13 23:04:00.061  2927-2927  RecentsImpl             com.miui.home                        W  onResumed className=com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity   mIsInAnotherPro=false   isKeyguardLocked=false
2023-11-13 23:04:00.074  1638-9159  MIUIInput               system_server                        D  [FoucsChange]: Display  0 FocusedWindow From Window{e9c80a4 mode=1 rootTaskId=2865 u0 io.ionic.starter/com.microsoft.appcenter.distribute.install.ReleaseInstallerActivity}(1,1)  to null(0,0)
2023-11-13 23:04:00.084 22248-22324 AppCenterAnalytics      io.ionic.starter                     D  onActivityResumed
2023-11-13 23:04:00.084 22248-22324 AppCenterAnalytics      io.ionic.starter                     D  noLogSentForLong=false wasBackgroundForLong=false
2023-11-13 23:04:01.036 22248-30115 AppCenterDistribute     io.ionic.starter                     E  Canceling installation due to lack of progress.
2023-11-13 23:04:01.036 22248-30115 AppCenterDistribute     io.ionic.starter                     D  Installation cancelled.

  1. Related issues: https://github.com/microsoft/appcenter-sdk-dotnet/issues/1633 https://github.com/microsoft/appcenter-sdk-android/pull/1631

LennonReid avatar Nov 21 '23 02:11 LennonReid

Thank you for submitting a new issue, @LennonReid.

For anyone else experiencing a similar problem, the context can be found here: https://github.com/microsoft/appcenter-sdk-android/issues/1680#issuecomment-1812615112.

Please feel free to upvote the issue or leave a comment if you are also affected.

DmitriyKirakosyan avatar Dec 07 '23 06:12 DmitriyKirakosyan

As we do not have plans to fix this bug in the next year, I'm closing the issue. However, contributions are still welcome.

DmitriyKirakosyan avatar Mar 27 '24 08:03 DmitriyKirakosyan

Do you have any plans to communicate with the Miui team to fix this issue? It seems it's related to them

hamid97m avatar Aug 09 '24 10:08 hamid97m

Hi guys,

I got the same error on Pixel 6 as well, and I fixed this issue by adjusting the CANCEL_TIMEOUT from 1000 to 3000. Can you take a look? @DmitriyKirakosyan

Thanks!

diff --git a/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/SessionReleaseInstaller.java b/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/SessionReleaseInstaller.java index 1e40d2b4d..46a4fbfaf 100644 --- a/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/SessionReleaseInstaller.java +++ b/sdk/appcenter-distribute/src/main/java/com/microsoft/appcenter/distribute/install/session/SessionReleaseInstaller.java @@ -57,7 +57,7 @@ public class SessionReleaseInstaller extends AbstractReleaseInstaller { /** * Timeout to check cancellation state in milliseconds. */

  • private static final long CANCEL_TIMEOUT = 1000;
  • private static final long CANCEL_TIMEOUT = 3000;

    /**

    • Install status receiver. Keep the reference to unsubscribe it.

francisleetang avatar Aug 26 '24 05:08 francisleetang

Hi @francisleetang , thanks for reaching out! Your case seems to be a duplicate of https://github.com/microsoft/appcenter-sdk-android/issues/1680.

What SDK version are you using? Could you enable verbose logging and check if you can find the log "Canceling installation due to lack of progress." in logcat?

DmitriyKirakosyan avatar Sep 03 '24 06:09 DmitriyKirakosyan

Hi @francisleetang , thanks for reaching out! Your case seems to be a duplicate of #1680.

What SDK version are you using? Could you enable verbose logging and check if you can find the log "Canceling installation due to lack of progress." in logcat?

Hey @DmitriyKirakosyan, thanks for replying.

I'm using 5.0.4 sdk, and yes, there's a log "Canceling installation due to lack of progress." when installation fails. Is it legal if I created sdk locally by myself with this fix and integrate the sdk in my app?

francisleetang avatar Sep 05 '24 02:09 francisleetang

@francisleetang , Thanks for the confirmation!

Yes, you can use your fork of the SDK to work around this issue. However, please note that this is not an officially supported solution, and we won't be able to provide support or troubleshoot any issues you may encounter with your modified version of the SDK.

DmitriyKirakosyan avatar Sep 05 '24 07:09 DmitriyKirakosyan

Can CANCEL_TIMEOUT be made configurable at runtime to avoid having to fork?

benjaminRomano avatar Nov 22 '24 06:11 benjaminRomano

Hi @benjaminRomano,

It seems they won’t address this because the repository is scheduled to be archived and will no longer be maintained after March 2025. When I raised this issue, I was informed that it wouldn’t be resolved for the same reason.

I’m sorry for the inconvenience, but you can still use version 4.3.1 or switch to the forked project until next year.

LennonReid avatar Nov 22 '24 09:11 LennonReid

It's a shame that this parameter was never exposed for configuration.

I tried some tricks to reflectively modify the private static final CANCEL_TIMEOUT but didn't end up having any luck with that approach. I assume things are more locked down in newer versions of Android.

I ended up forking AppCenter SDK 😕

benjaminRomano avatar Nov 28 '24 03:11 benjaminRomano