1、adb install強制安裝在SD卡
因為盒子/data/空間不夠了。而默認apk就安裝在了/data/目錄下。因此需要更改默認安裝位置
命令參照
進入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卡上
關於指定安裝路徑這一部分,我又找了一些參考的。問題和我一樣,后面有機會可以測試下,這里我沒測試
參考地址 https://www.cnblogs.com/eustoma/p/4059542.html 實例:如何在海信2.2 STB上將APK安裝到U盤中: 首先嘗試使用: pm set-install-location 2 之后安裝之,沒有用。 后來做如下嘗試: 在其它設置->存儲設備->制定默認存儲設備中選擇U盤為默認存儲設備。 # pm install -s xxxx.apk 就可以成功。
2、adb安裝apk報錯Failure [INSTALL_FAILED_INVALID_URI]
很可能原因是包不存在,或者路徑寫錯了。
我這里是包因為垃圾清理時刪除了。然后沒注意到,執行安裝報了這個錯誤
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]
3、盒子存儲空間不夠
導致安裝報如下錯誤
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 來源:簡書 著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。
4、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
5、常用命令
進入終端: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(目的地路徑)
6、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) 重啟手機,重新連接。
