2015-11-17 49 views
0

今天我發現我無法從Android工作室運行我的應用程序到我的設備,這裏是日誌。爲什麼`pm install`和其他pm命令在我的設備上不起作用?

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. 

看來包複製到設備中,但在執行shell命令pm install時,它只是不能認識到這一點的命令?

我也嘗試過其他人,比如pm clear左右,也不行。

而我試過adb install -r .....apk,我可以看到發送的文件,但沒有任何成功或失敗的結果顯示。

安裝應用程序的唯一方法是手動方式,將apk複製到設備中並打開apk文件。

我的設備是根目錄和USB調試是打開,我試過在不同的計算機,但結果相同。

任何人都知道如何處理這種情況?

+0

重新啓動我的手機,重新啓動我的電腦,清理並重建項目,我的朋友的電話沒問題,只有我的手機像這樣。 – Aloong

+0

1)你想使用這個命令來安裝嗎?或者當您嘗試使用android studio進行安裝時,這是日誌。 2)這隻發生在所有手機上,或者只發生在您的小米手機中,如您在評論中提到的那樣?' – Darpan

+0

@Darpan當我嘗試運行應用程序時,日誌顯示在Android Studio中,但也顯示當我再次嘗試時命令行。這似乎只發生在一部手機上。 – Aloong

回答

0

看起來像Android N改變了PM命令;您需要使用pm install-create,install-write和install-commit。不幸的是,我無法弄清楚安裝寫入的語法,幫助文本非常差。

+0

對不起,我誤解了,這個變化比N更舊。無論我怎麼在網上找不到關於如何使用它的最新指令。 – user169771

0

您是否檢查過您的有效UID權限和shell (2000)的?這可能會導致Android L +中的一些錯誤。

相關問題