一、adb install強制安裝在SD卡html
由於盒子/data/空間不夠了。而默認apk就安裝在了/data/目錄下。所以須要更改默認安裝位置shell
命令參照緩存
進入adb shell $adb shell $pm set-install-location 0 pm set-install-location 0 由app自行決定軟件可否安裝在sd卡 pm set-install-location 1 強制所有app安裝在rom內 pm set-install-location 2 強制所有app安裝在sd卡 同時能夠用pm set-install-location獲取當前安裝地址的信息,返回0,1,2描述同上
然而我發現實際機頂盒安裝的時候依然是安裝到了本機存儲上,而不是sd卡上bash
關於指定安裝路徑這一部分,我又找了一些參考的。問題和我同樣,後面有機會能夠測試下,這裏我沒測試session
參考地址 https://www.cnblogs.com/eustoma/p/4059542.html 實例:如何在海信2.2 STB上將APK安裝到U盤中: 首先嚐試使用: pm set-install-location 2 以後安裝之,沒有用。 後來作以下嘗試: 在其它設置->存儲設備->制定默認存儲設備中選擇U盤爲默認存儲設備。 # pm install -s xxxx.apk 就能夠成功。
二、adb安裝apk報錯Failure [INSTALL_FAILED_INVALID_URI]app
極可能緣由是包不存在,或者路徑寫錯了。ide
我這裏是包由於垃圾清理時刪除了。而後沒注意到,執行安裝報了這個錯誤測試
shell@orange:/ # cd /mnt/usb/ cd /mnt/usb/ shell@orange:/mnt/usb # pm install zyqp-release.apk pm install zyqp-release.apk pkg: zyqp-release.apk Failure [INSTALL_FAILED_INVALID_URI] shell@orange:/mnt/usb # pm install /mnt/usb/zyqp-release.apk pm install /mnt/usb/zyqp-release.apk pkg: /mnt/usb/zyqp-release.apk Failure [INSTALL_FAILED_INVALID_URI]
三、盒子存儲空間不夠ui
致使安裝報以下錯誤this
Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]
這裏由於默認都是安裝到了/data/目錄下的,空間不夠致使失敗
shell@orange:/mnt/usb # pm install zyqp-release.apk pm install zyqp-release.apk pkg: zyqp-release.apk Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE] shell@orange:/mnt/usb # df df Filesystem Size Used Free Blksize /dev 419.1M 220.0K 418.9M 4096 /sys/fs/cgroup 419.1M 12.0K 419.1M 4096 /mnt/secure 419.1M 0.0K 419.1M 4096 /mnt/asec 419.1M 0.0K 419.1M 4096 /mnt/obb 419.1M 0.0K 419.1M 4096 /mnt/usb 419.1M 14.2M 404.9M 4096 /mnt/iso 419.1M 0.0K 419.1M 4096 /mnt/samba 419.1M 0.0K 419.1M 4096 /storage/external_storage 419.1M 0.0K 419.1M 4096 /var 419.1M 3.1M 416.0M 4096 /system 678.0M 457.0M 221.0M 4096 /cache 991.9M 292.0K 991.6M 4096 /data 495.9M 422.9M 73.1M 4096 /tvservice 55.0M 18.5M 36.6M 4096 /tvconfig 5.8M 2.7M 3.1M 4096 /tvdatabase 3.9M 304.0K 3.6M 4096 /tvcustomer 11.7M 40.0K 11.7M 4096 /flashdata 15.7M 56.0K 15.6M 4096 /mnt/shell/emulated 495.9M 422.9M 73.1M 4096 /data/vmtmp 4.0M 24.0K 4.0M 4096 /mnt/media_rw/sdcard0 1.8G 1.6G 262.4M 32768
如下空間能夠清理
除了卸載沒必要要的APP以及整理照片、視頻,還能夠手動刪除一些系統文件。
好比在/data/local/目錄,其中的tmp就是緩存文件,將它們所有刪除。
另外在/data/dalvik-cache中則是系統緩存文件和卸載程序後留下來的無用記錄文件,能夠放心所有刪除。(刪除後可能會提醒部分APP中止運行,沒必要擔憂)系統所需文件重啓後就能自動生成。
這個報錯的特殊狀況(我沒遇到過,別人遇到的)
Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE] 其實,在應用第一次安裝的時候,APK 文件會被保存在以下路徑中: /data/app/<package-name>-1.apk 當這個 APK 文件更新,須要從新安裝以後, APK 會從新被保存在相同的目錄中,可是文件的序號會相應增長。而後以前一個版本的 APK -1.apk文件會被刪除。 /data/app/<package-name>-2.apk 若是這時又有了一個新版本的 APK 須要安裝,那麼這個文件又會被保存爲 -1.apk, 相應的,-2.apk 也會被刪除。以此類推,若是又有新的 APK, 那麼這個邏輯會一直交替下去。 而 INSTALL_FAILED_INSUFFICIENT_STORAGE 錯誤發生的狀況中,大部分是由於 APK 更新以後, /data/app/ 裏的文件刪除失敗, -1.apk 和 -2.apk 殘留致使的。 解決辦法 因此,很簡單,在安裝以前先清除 /data/app/ 下對應包名的文件就行了。解決方法以下: adb shell pm uninstall <full.packge.name> adb shell rm -rf /data/app/<full.package.name>-* 做者:_Ryeeeeee 連接:https://www.jianshu.com/p/4eb025c13a48 來源:簡書 著做權歸做者全部。商業轉載請聯繫做者得到受權,非商業轉載請註明出處。
四、adb模式下pm命令詳解
pm install 安裝應用 pm unitall 卸載應用 pm clear 清除應用緩存
介紹adb shell中一個很重要的命令——pm(Package Manager),這個命令主要用於獲取和安裝在 Android 設備上的應用信息。
安裝APK: pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH PATH 指 APK文件絕對路徑和文件名。 例如: pm install /data/3dijoy_fane.apk 這幾個參數頗有用: -r: 安裝一個已經安裝的APK,保持其數據不變。 -i:指定安裝的包名。(沒試出來) -s: 安裝到SDCard上。 -f: 安裝到內部Flash上。 卸載APK: pm uninstall 包名。 例如: pm uninstall com.TDiJoy.fane
關於pm命令的用法解析。命令行下輸入adb shell pm便可得到關於pm的用法幫助,以下所示:
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 <TARGET-PACKAGE> 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
五、經常使用命令
進入終端:adb shell 安裝APK:adb push xxx(apk所在的路徑) xxx(apk將要安裝的路徑下,即目的地路徑) 或adb install xxx(apk所在的路徑) xxx(apk將要安裝的路徑下,即目的地路徑); 移除APK:rm xxx.apk 或 rm -rf xxx.apk 鏈接盒子:adb connect 192.168.160.1(盒子的ip地址,這個得換成本身盒子得ip) 斷開盒子:adb disconnect 192.168.160.1(盒子的ip地址,這個得換成本身盒子得ip) 修改系統讀寫權限:adb remount 或mount -o remount /system 殺死服務:adb kill-server 查看設備信息:adb devices 打印log信息:adb logcat 重啓:adb reboot 展現內容列表:ll 或 ls 終端拷貝文件:copy xxx(源文件路徑) xxx(目的地路徑)
六、adb 命令提示設備offline
參考地址
https://www.cnblogs.com/mgzc-1508873480/p/6994597.html
adb devices 提示offline 問題緣由:adb版本太舊,舊版本不支持4.2.2以上系統或小米V5 解決方法:更新adb版本 操做步驟: 1) 檢查adb版本:adb version; 2) 更新到1.0.31或以上版本:sudo find / -name adb 3) 拔掉usb線,從新鏈接 4) 若是adb版本已更新到1.0.31,但仍存在offline問題,則更新platform tool到16.0.1以上版本; 5) 重啓手機,從新鏈接。