0

Today I found I can't run my app from Android studio to my device, here is the log.

Target device: xiaomi-mi_note_pro-21712f58
Uploading file
    local path: E:\weiyun\workspace\xkm\iKM\build\outputs\apk\iKM-debug.apk
    remote path: /data/local/tmp/com.ikm
Installing com.ikm
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.ikm"
usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_ID] [FILTER]
       pm list permission-groups
       pm list permissions [-g] [-f] [-d] [-u] [GROUP]
       pm list instrumentation [-f] [TARGET-PACKAGE]
       pm list features
       pm list libraries
       pm list users
       pm path PACKAGE
       pm dump PACKAGE
       pm install [-lrtsfd] [-i PACKAGE] [PATH]
       pm install-create [-lrtsfdp] [-i PACKAGE] [-S BYTES]
       pm install-write [-S BYTES] SESSION_ID SPLIT_NAME [PATH]
       pm install-commit SESSION_ID
       pm install-abandon SESSION_ID
       pm uninstall [-k] [--user USER_ID] PACKAGE
       pm set-installer PACKAGE INSTALLER
       pm clear [--user USER_ID] PACKAGE
       pm enable [--user USER_ID] PACKAGE_OR_COMPONENT
       pm disable [--user USER_ID] PACKAGE_OR_COMPONENT
       pm disable-user [--user USER_ID] PACKAGE_OR_COMPONENT
       pm disable-until-used [--user USER_ID] PACKAGE_OR_COMPONENT
       pm hide [--user USER_ID] PACKAGE_OR_COMPONENT
       pm unhide [--user USER_ID] PACKAGE_OR_COMPONENT
       pm grant PACKAGE PERMISSION
       pm revoke PACKAGE PERMISSION
       pm set-install-location [0/auto] [1/internal] [2/external]
       pm get-install-location
       pm set-permission-enforced PERMISSION [true|false]
       pm trim-caches DESIRED_FREE_SPACE
       pm create-user [--profileOf USER_ID] [--managed] USER_NAME
       pm remove-user USER_ID
       pm get-max-users

pm list packages: prints all packages, optionally only
  those whose package name contains the text in FILTER.  Options:
    -f: see their associated file.
    -d: filter to only show disbled packages.
    -e: filter to only show enabled packages.
    -s: filter to only show system packages.
    -3: filter to only show third party packages.
    -i: see the installer for the packages.
    -u: also include uninstalled packages.

pm list permission-groups: prints all known permission groups.

pm list permissions: prints all known permissions, optionally only
  those in GROUP.  Options:
    -g: organize by group.
    -f: print all information.
    -s: short summary.
    -d: only list dangerous permissions.
    -u: list only the permissions users will see.

pm list instrumentation: use to list all test packages; optionally
  supply  to list the test packages for a particular
  application.  Options:
    -f: list the .apk file for the test package.

pm list features: prints all features of the system.

pm list users: prints all users on the system.

pm path: print the path to the .apk of the given PACKAGE.

pm dump: print system state associated with the given PACKAGE.

pm install: install a single legacy package
pm install-create: create an install session
    -l: forward lock application
    -r: replace existing application
    -t: allow test packages
    -i: specify the installer package name
    -s: install application on sdcard
    -f: install application on internal flash
    -d: allow version code downgrade
    -p: partial application install
    -S: size in bytes of entire session

pm install-write: write a package into existing session; path may
  be '-' to read from stdin
    -S: size in bytes of package, required for stdin

pm install-commit: perform install of fully staged session
pm install-abandon: abandon session

pm set-installer: set installer package name

pm uninstall: removes a package from the system. Options:
    -k: keep the data and cache directories around after package removal.

pm clear: deletes all data associated with a package.

pm enable, disable, disable-user, disable-until-used: these commands
  change the enabled state of a given package or component (written
  as "package/class").

pm grant, revoke: these commands either grant or revoke permissions
  to applications.  Only optional permissions the application has
  declared can be granted or revoked.

pm get-install-location: returns the current install location.
    0 [auto]: Let system decide the best location
    1 [internal]: Install on internal device storage
    2 [external]: Install on external media

pm set-install-location: changes the default install location.
  NOTE: this is only intended for debugging; using this can cause
  applications to break and other undersireable behavior.
    0 [auto]: Let system decide the best location
    1 [internal]: Install on internal device storage
    2 [external]: Install on external media

pm trim-caches: trim cache files to reach the given free space.

pm create-user: create a new user with the given USER_NAME,
  printing the new user identifier of the user.

pm remove-user: remove the user with the given USER_IDENTIFIER,
  deleting all data associated with that user



Launching application: com.ikm/com.ikm.MainActivity.
DEVICE SHELL COMMAND: am start  -n "com.ikm/com.ikm.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.ikm/.MainActivity }
Error type 3
Error: Activity class {com.ikm/com.ikm.MainActivity} does not exist.

It seems the package is copied into the device, but when executing the shell command pm install, it just can't recognize this command?

I also tried others like pm clear or so, also not working.

And I tried adb install -r .....apk, I can see the file sent but no any success or fail result showed.

The only way to install a app is the manual way, copy the apk into the device and open the apk file.

My device is rooted and usb debugging is on, I tried in different computer but the same result.

Anyone knows how to deal with this situation?

Aloong
  • 1,715
  • 6
  • 23
  • 40
  • Restarted my phone, restarted my computer, cleaned and rebuilt the project, my friend's phone is ok, only my phone acts like this. – Aloong Nov 17 '15 at 08:31
  • 1) are you trying to install using this command? or this is the log when you try to install using android studio. 2) this is only happening on all phones or only your Xiaomi phone as you mentioned in the comment?` – Darpan Nov 17 '15 at 08:33
  • @Darpan The log is shown in Android Studio when I try to run the app, but also shows when I try it again in the command lines. And this seems only happens to one phone. – Aloong Nov 17 '15 at 08:41
  • com.ikm.MainActivity - this class exists? (I bet it would, just asking) – Darpan Nov 17 '15 at 08:44
  • @Darpan This is the result, the reason is that `pm install` not working at all, so there is no such activity installed. – Aloong Nov 17 '15 at 08:58
  • I use adb install -r "path/of/the/apk" and that works for me instead of using package name of the app. Checked it on a Xiaomi device. if that too does not work, its your device. – Darpan Nov 17 '15 at 09:06

3 Answers3

1

Have you checked your effective UID's permissions and shell (2000)'s? That can cause some errors in Android L+.

iBug
  • 35,554
  • 7
  • 89
  • 134
0

Looks like Android N has changed the PM command; You need to use pm install-create, install-write, and install-commit. Unfortunately I can't figure out the syntax for install-write, the help text is very poor.

user169771
  • 1,962
  • 2
  • 13
  • 11
  • Sorry, I was mistaken, the change is older than N. Regardless I can find no up-to-date instructions online about how to use it. – user169771 Jul 15 '16 at 19:37
  • I don't think so? It still supports pm install – Le-roy Staines Aug 23 '19 at 05:15
  • I don't know how to use it via PC, but via a rooted device you can check here: https://stackoverflow.com/a/60355502/878126 , and if you want without root, here: https://stackoverflow.com/a/55672367/878126 . I have no idea why " specify the installer package name" exists though. Seems to work without it. – android developer Mar 14 '20 at 17:46
0

For simple installing, check this out. You need to use:

cat [FULL_PATH_TO_APK_FILE] | pm install -S [APK_FILE_SIZE]

For split-apk files, it becomes more complicated, as I've written here

android developer
  • 114,585
  • 152
  • 739
  • 1,270