Android 无需 root 卸载系统应用
卸載應(yīng)用的命令
adb shell pm uninstall [-k] [--user USER_ID] 包名
-k : 卸載應(yīng)用但保留數(shù)據(jù)和緩存 --user 指定用戶 id : Android 系統(tǒng)支持多個(gè)用戶,默認(rèn)系統(tǒng)用戶只有一個(gè),id=0。卸載系統(tǒng)應(yīng)用(例:系統(tǒng)自帶的計(jì)算器)
- 不指定用戶ID
當(dāng)我們不設(shè)置用戶ID的時(shí)候,卸載系統(tǒng)應(yīng)用是不成功的。
adb shell pm uninstall com.android.calculator2
返回:
Failure [DELETE_FAILED_INTERNAL_ERROR]- 指定用戶ID
當(dāng)我們?cè)O(shè)置了用戶ID為系統(tǒng)用戶即id=0時(shí),可以成功的卸載系統(tǒng)應(yīng)用。
adb shell pm uninstall --user 0 com.android.calculator2
返回:
Success所以,當(dāng)我們想卸載系統(tǒng)應(yīng)用時(shí),我們只需要指定其id=0即可。
那對(duì)于那些不知道其包名的應(yīng)用怎么辦?
通過(guò)下面的方法獲取包名即可。
查看APP的包名
打開(kāi)APP,然后再輸入如下命令:
- Linux系統(tǒng)
adb shell dumpsys window | grep mCurrentFocus
- Windows系統(tǒng)
adb shell dumpsys window | findstr mCurrentFocus
結(jié)果:
mCurrentFocus=Window{d7e79b8 u0 com.android.calculator2/com.android.calculator 2.Calculator}通過(guò)這個(gè)命令我們就可以獲取當(dāng)前應(yīng)用的包名和Activity名了。
恢復(fù)出廠設(shè)置
當(dāng)我們不小心把系統(tǒng)核心應(yīng)用給卸載了怎么辦?那就只能恢復(fù)出廠設(shè)置來(lái)解決了。如果有幸,你的設(shè)備Launcher應(yīng)用可以正常使用,那就打開(kāi)系統(tǒng)設(shè)置,然后去恢復(fù)出廠設(shè)置即可。如果無(wú)法操作系統(tǒng)設(shè)置怎么辦?那就使用adb命令的方法來(lái)實(shí)現(xiàn)。以前有一種發(fā)廣播的方式adb shell am broadcast -a android.intent.action.MASTER_CLEAR,但現(xiàn)在好像實(shí)現(xiàn)不了。來(lái)看看用adb的方式:
adb root adb shell "echo \"--wipe_data\" > /cache/recovery/command" adb reboot recovery總結(jié)
我們想要卸載應(yīng)用(包括系統(tǒng)應(yīng)用)只需要分兩步:
第一步:獲取應(yīng)用的包名(當(dāng)前打開(kāi)的應(yīng)用)
Windows 系統(tǒng):
adb shell dumpsys window | findstr mCurrentFocus
或者 Linux 系統(tǒng):
adb shell dumpsys window | grep mCurrentFocus
第二步:使用卸載命令
adb shell pm uninstall --user 0 包名
總結(jié)
以上是生活随笔為你收集整理的Android 无需 root 卸载系统应用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Android:adb卸载系统应用软技能
- 下一篇: Android 黑科技之卸载系统应用(卸