shorebird icon indicating copy to clipboard operation
shorebird copied to clipboard

fix: `shorebird preview` fails with CLEAR_APP_USER_DATA permission error on some phones

Open eseidel opened this issue 1 year ago • 5 comments

✓ Fetching releases (0.5s)
Which release would you like to preview?
Which release would you like to preview? 1.1.1.1+1111
✓ Using production track (1.8s)
✓ Extracting metadata (0.7s)
✓ Building apks (5.6s)
✓ Installing apks (33.3s)
✗ Exception: Unable to clear app data: Security exception: PID 7149 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.example.app

java.lang.SecurityException: PID 7149 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package com.example.app
        at com.android.server.am.ActivityManagerService.clearApplicationUserData(ActivityManagerService.java:4538)
        at com.android.server.pm.PackageManagerShellCommand.runClear(PackageManagerShellCommand.java:1852)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:216)
        at android.os.ShellCommand.exec(ShellCommand.java:104)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:24260)
        at android.os.Binder.shellCommand(Binder.java:881)
        at android.os.Binder.onTransact(Binder.java:765)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5118)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4883)
        at com.android.server.pm.OppoPackageManagerService.onTransact(OppoPackageManagerService.java:91)
        at android.os.Binder.execTransactInternal(Binder.java:1021)
        at android.os.Binder.execTransact(Binder.java:994)

Originally posted by @imeDevelopers in https://github.com/shorebirdtech/shorebird/issues/1696#issuecomment-1924956382

eseidel avatar Mar 29 '24 03:03 eseidel

I've seen one stack overflow say this is related to not having USB debugging enabled? https://stackoverflow.com/questions/24755341/unable-to-get-android-permission-clear-app-user-data

I've seen another say that this is related to certain OS phone vendors having buggy adbd (the daemon on the phone that handles the device's side of adb). https://github.com/appium/appium/issues/9807

eseidel avatar Mar 29 '24 03:03 eseidel

I don't think there is anything for us to do here atm, other than potentially improve the failure message?

eseidel avatar Jun 12 '24 20:06 eseidel

Hey, I have exactly the issue on POCO phones, and this comment in stack overflow resolved that.

It would be good to have that info in the improved failure message OR a link to an FAQ as this issue is not present during the normal development process

tomaszpolanski avatar Dec 13 '24 15:12 tomaszpolanski

is this error occurs in release build? or only in preview

Zubairpv avatar Feb 21 '25 14:02 Zubairpv

We've started using a pattern for augmenting logs with more clear failure messages, which we could use here. (e.g. https://github.com/shorebirdtech/shorebird/commit/0391b31c38fba8a11c687f6df988494ebc0be01a ) It's probably a while until we get to that though, we're pretty busy with other issues at the moment.

eseidel avatar Feb 26 '25 16:02 eseidel