vidstige / jadb

ADB Client in pure Java.
Apache License 2.0
640 stars 178 forks source link

Android 10, exception in PackageManager.forceInstall(...) #122

Closed BOOtak closed 2 months ago

BOOtak commented 5 years ago

When I try to force install any application on an emulator with Android 10 using Jadb API call PackageManager.forceInstall, it throws the following exception:

se.vidstige.jadb.JadbException: Could not install <APP NAME>.apk: 
Exception occurred while executing:
java.lang.IllegalArgumentException: No argument expected after "-r "
    at android.os.ShellCommand.getNextOption(ShellCommand.java:266)
    at com.android.server.pm.PackageManagerShellCommand.makeInstallParams(PackageManagerShellCommand.java:2383)
    at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1057)
    at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:169)
    at android.os.ShellCommand.exec(ShellCommand.java:104)
    at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21729)
    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:4860)
    at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4014)
    at android.os.Binder.execTransactInternal(Binder.java:1021)
    at android.os.Binder.execTransact(Binder.java:994)

    at se.vidstige.jadb.managers.PackageManager.verifyOperation(PackageManager.java:47)
    at se.vidstige.jadb.managers.PackageManager.install(PackageManager.java:65)
    at se.vidstige.jadb.managers.PackageManager.installWithOptions(PackageManager.java:78)
    at se.vidstige.jadb.managers.PackageManager.forceInstall(PackageManager.java:82)

I've assumed that PackageManager uses simple pm install -r call under the hood, and this command changed in format in Android 10, but, surprisingly, calling pm install -r <PKNAME> manually from adb shell still works, as well as calling adb install -r <PKNAME>

vidstige commented 2 months ago

I think this has been fixed, but can't test anymore 🙈