Tony Stark
Tony Stark

Reputation: 2468

Debugging Android apps via IntelliJ/Android SDK on my Samsung Galaxy S10+ results in "Error while Installing APKs"

I decided to generate even more money and develop my first app for Android. When I want to deploy my app (just the skeleton code from IntelliJ/Android SDK) with one MainActivity I am getting the following error.

enter image description here

The log of the run looks like this.

5/07 21:32:35: Launching app

$ adb install-multiple -r -t

C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_7.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_6.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_8.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_9.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_4.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_5.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_3.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\resources\instant-run\debug\resources-debug.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_0.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_1.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\dep\dependencies.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\split-apk\debug\slices\slice_2.apk C:\Users\Tony\Code\Java\PureWallpaper\app\build\intermediates\instant-run-apk\debug\app-debug.apk

$ adb shell pm uninstall com.stark.purewallpaper

Unknown failure: Exception occurred while executing: java.lang.IllegalArgumentException: Unknown package: com.stark.purewallpaper at com.android.server.pm.Settings.getInstallerPackageNameLPr(Settings.java:4671) at com.android.server.pm.PackageManagerService.getInstallerPackageName(PackageManagerService.java:25342) at com.android.server.pm.PackageManagerService.isOrphaned(PackageManagerService.java:25348) at com.android.server.pm.PackageManagerService.deletePackageVersioned(PackageManagerService.java:21062) at com.android.server.pm.PackageInstallerService.uninstall(PackageInstallerService.java:924) at com.android.server.pm.PackageManagerShellCommand.runUninstall(PackageManagerShellCommand.java:1486) at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:193) at android.os.ShellCommand.exec(ShellCommand.java:103) at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:25884) at android.os.Binder.shellCommand(Binder.java:642) at android.os.Binder.onTransact(Binder.java:540) at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:3329) at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4763) at android.os.Binder.execTransact(Binder.java:739) Error while Installing APKs

The event log looks like this.

21:32 Executing tasks: [:app:assembleDebug] 21:32 Gradle build finished in 493 ms 21:32 Failed to finalize session : -118

Things I tried on the phone:

Things I tried in IntelliJ:

IntelliJ can clearly see my device, it even detects the type correctly.

enter image description here

I am on:

I decided to try this on Android Studio 3.4 and I'm getting same error.

enter image description here

I am able to run the app inside the emulator/virtual device but not on my Samsung Galaxy S10+. Any ideas?

Upvotes: 3

Views: 1423

Answers (5)

Ashad
Ashad

Reputation: 2513

This was happen to me many times ,

This is just a warning ,It try to say that the app you want to install on your device is already installed on your device ,but the problem is it is signed with different credentials .

For eg:- their was a release apk of the same app installed on your device and you are trying to install debug apk on same device.

This error also try to say that the that all the data which are saved by that apk will be lost.

Side note:- after clicking OK,sometimes android studio gives me error that it is unable to install but actually it installed.

Upvotes: 0

Shakil Ahmed Shaj
Shakil Ahmed Shaj

Reputation: 556

If none of the solution mentioned above works, you can turn off the instant run option as shown in the image from setting

Upvotes: 5

Tony Stark
Tony Stark

Reputation: 2468

I finally, after days, found out what it was. My company forced a security policy on my phone after I configured the e-mail app to receive work mail. After deactivating the policy in security settings I was able to deploy the app without any problems.

Upvotes: 4

No Name
No Name

Reputation: 470

Try this:

  1. Build > Clean Project
  2. Build > Rebuild Project
  3. Build > Make Project (Ctrl + F9)
  4. Try to use this File > Invalidates cache/restart

Lastly, try to sync project with Gradle file which can be found in the right corner top

Upvotes: 4

shizhen
shizhen

Reputation: 12583

  1. Go to your Apps menu from your Android device Settings.
  2. Find your app, probably name is PureWallpaper according to your logs.
  3. Uninstall it.
  4. Then try to install it again.

Explanation:

According to your error logs, it looks like your device has the same app installed but with different signature signed with different keystore.

Upvotes: 2

Related Questions