WrRaThY
WrRaThY

Reputation: 1998

Expo: android app stopped installing after "work" profile got installed onto my phone

I had an expo based react-native app that worked perfectly when I had only personal profile on my phone. Lately I also connected "Work profile" on my Samsung S20 and now I can't develop my personal app.

I'm running a typical expo build:

  "scripts": {
    "android": "expo run:android",

The error that I'm getting: expo build error

I managed to recreate the problem somehow by running:

$ adb shell pm list packages

Exception occurred while executing 'list':
java.lang.SecurityException: Shell does not have permission to access user 10
 com.android.server.am.ActivityManagerService.handleIncomingUser:14872 android.app.ActivityManager.handleIncomingUser:4802 com.android.server.pm.PackageManagerShellCommand.translateUserId:3499
        at com.android.server.am.UserController.handleIncomingUser(UserController.java:2672)

and indeed - I have more users now:

Users:
        UserInfo{0:MyUsername:c13} running
        UserInfo{10:Work profile:1030} running
        UserInfo{150:Secure Folder:10021030} running

then I found a fix for the

adb shell pm list packages --user 0

but I have no idea how can I provide this parameter to expo builds. Please advise.

Upvotes: 3

Views: 660

Answers (1)

armyofda12mnkeys
armyofda12mnkeys

Reputation: 3442

On the command line let say you run:

adb shell pm list users

which lists the users/profiles on the phone... The main user is 0 i think, but the work profile is the other # which is in the "Shell does not have permission to access user ###" error msg.

I saw on a github issue you can force adb shell to use the 0 zero to fix as a tempfix (until expo fixes their cli to handle work profiles): "In your project, open the file node_modules/@expo/cli/build/src/start/platforms/android/adb.js, and replace the adbArgs function with this:

function adbArgs(pid, ...options) {
    const args = [];
    if (pid) {
        args.push("-s", pid);
    }

    // Add the --user param whenever Expo tries to call `adb shell pm list packages`
    options = options.map(option => {
        if (option === "packages") {
            return "packages --user 0";
        }
        return option;
    });

    return args.concat(options);
}

Reference: https://github.com/expo/expo/issues/22473

Upvotes: 0

Related Questions