Search code examples
androidandroid-studioadb

Android Studio pm install aborted


Im trying to run an application on my GS5 from android studio and Im getting this:

Waiting for device.
Target device: samsung-sm_g900v-f3af9744
Uploading file
local path: D:\Android\Projects\TestProject\build\outputs\apk\TestProject-debug.apk
remote path: /data/local/tmp/com.brian.testproject
Installing com.datascan.mobilescripts
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.brian.testproject"
Aborted

It seems to be copying the file to the device, I can see it in the /data/local/tmp directory. Its just failing at the "pm install" stage.

On the phone I turned on USB Debugging and authorized the computer. Here is what I get when I run ADB devices:

D:\Android\sdk\platform-tools>adb devices
List of devices attached
f3af9744        device

So that seems to be correct. Im not really sure what the problem is. Google search on the problem didnt give me any relevant results.

Does anyone know how to get more information beyond "Aborted"? Any help is appreciated, Thanks!

EDIT:

As suggested by @AlexP. I ran "adb logcat -d -s PackageManager:*", this was the result:

D:\Android\sdk\platform-tools>adb logcat -d -s PackageManager:*
--------- beginning of main
--------- beginning of system

Not much help, but I did decide to watch the logcat as the pm install was being run and I found this error entry:

Tag=appproc  |  Text= ERROR: Could not find class 'com.android.commands.pm.Pm'
Tag=art      |  Text= art.runtime/thread.cc:1105] No pending exeption expected: java.lang.ClassNotFoundException: Didn't find class "com.android.commands.pm.Pm" on path: DexPathList[[zip file "/system/framework/pm.jar"],nativeLibraryDirectories=]/vendor/lib, /system/lib]]

Followed by a whole slew of art error entries.

So it seems as though my phone is missing something, maybe?


Solution

  • The reason that Android Studio fails on Galaxy S5 is because the adbd (ADB service on the phone not your PC), on rooted version of this phone does not run as root, which is a security measure. You can verify this by manually trying to execute the Android Studio apk and execute commands on the device and finding out that they are failing to execute, but retrying them using "su ..." and see that the app installs and starts on the device. There are three options to resolve this and unblock Android Studio:

    Options:

    1. Flash a ROM that includes the modification - not desired as from my understanding you would like to stay on the stock image; also a good security measure not to have adbd running as root all the time. Older roms fall in this category as well, but then you are missing Stock Rom updates and security patches.
    2. Create a custom boot.img and flash it to your phone - this is basically a custom kernel and not desired for a similar reasons than above option 1.
    3. Restart adbd on your device with root privileges when doing app development - preferred and achievable fairly easy thru various methods including:

    Preferred Solution:

    a. Restart adbd with root privileges (insecure mode) by killing the service on the phone and using a terminal app or so to restart it using "su". After you are done with your app development, restart your phone and adbd will be back in secure mode, restoring the security measures.

    b. Use Chainfire's ADB insecure app, which is free on XDA (download/link below) or pay for it on Google Play to support his work. You can toggle the mode in the app. In the app, you also have an option to auto re-enable the insecure mode on reboots.

    References:

    https://android.stackexchange.com/questions/5884/is-there-a-way-for-me-to-run-adb-shell-as-root-without-typing-in-su

    http://forum.xda-developers.com/showthread.php?t=1687590 (includes free download link)

    https://play.google.com/store/apps/details?id=eu.chainfire.adbd (for supporting Chainfire's work)