删除模拟器中的应用程序(.apk)?
我知道从模拟器中删除正在开发的应用程序的两种方法:
- 使用模拟器 GUI:设置> 应用领域>>管理应用程序> 使用 ADB卸载
- : adb uninstall
我可能已经发现了第三种方法,即使用“adb shell”:
rm /data/app/<package>.apk
但是,这似乎并不是删除应用程序的好方法,因为可能存在与之相关的其他信息(注册?) 。
该信息是什么以及在哪里可以找到?
I know of two ways of deleting an app under development from the emulator:
- Using the emulator GUI: Settings >
Applications > Manage Applications >
Uninstall - Using ADB: adb uninstall
I may have discovered a third way, using 'adb shell':
rm /data/app/<package>.apk
It seems, however, that this isn't really a good way to delete apps because there may be additional information associated with it (registration?).
What is that information and where can it be found?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你提到这一点很有趣。我进行了一个快速的家庭测试,以阐明您的问题。
通常,当您安装.apk文件时,Android会为其创建一个内部存储区域,位于/data/data/<启动活动的包名>。这主要用作内部缓存区域,其他应用程序或手机用户无法访问。您可以在 Internal 中更详细地了解这一点Android 数据存储部分的存储章节。这是您的应用程序专用的区域,您可以在那里写入私有数据。
理论上一旦卸载应用程序,该内部存储区域也会被删除。您概述的前两种方法确实可以做到这一点:删除 /data/app/ 中的 .apk 文件以及 /data/data/ 中的内部存储区域。
但是,如果您使用 adb shell 并运行 rm 命令,则删除的只是 /data/app/ 中的 .apk 文件。 /data/data/中的内部存储区域不会被删除。因此,本质上您是正确的,应用程序的附加信息不一定会被删除。但另一方面,如果您在运行命令后重新安装应用程序,则现有的内部存储区域将被覆盖,因为正在安装它的新副本。
It's interesting you mention this. I ran a quick home made test to shed some light onto your question.
Generally, when you install a .apk file, Android creates an internal storage area for it located at /data/data/< package name of launching activity>. This is mainly used as an internal caching area that cant be accessed by other apps or the phone user. You can read up about that in a little bit more detail in the Internal storage chapter of Androids data storage section. It is an area exclusively used by your app and you can write private data there.
Once you uninstall an app theoretically, this internal storage area is also deleted. The first 2 ways which you outlined indeed does that: the .apk file in /data/app/ is deleted aswell as the internal storage area in /data/data/.
However if you used adb shell and run the rm command, all that is removed is the .apk file in /data/app/. The internal storage area in in /data/data/ is not deleted. So in essence you are correct that additional information with the app is not necessarily deleted. But on the flip side, if you reinstall the app after running the command, then the existing internal storage area gets overwritten as a fresh copy of it is being installed.
adb uninstall com.example.test
com.example.test 可能会因您的应用而异。
adb uninstall com.example.test
com.example.test may vary acording to your app.
我也遇到了这个问题。我的手机上有 Link2SD,但 SD 卡上的 ext4 分区已损坏,因此我重新格式化,但所有链接的文件仍在 /data/app 文件夹中。所以我创建了一个脚本来删除所有损坏的链接,并遇到了与您相同的问题,应用程序管理器说它们仍然安装了!所以我使用手机上的 pm 程序编写了另一个脚本来解决这个问题。
这是我的代码,用于从应用程序文件夹中删除损坏的链接:
这是我卸载没有 apk 的应用程序的代码:
将这些文件复制到您的手机,然后不带任何参数运行它们以查看发现的内容,或者在末尾添加修复 (fixmissing.sh 修复) 以使它们修复发现的内容。运行风险由您自行承担,并备份您的文件。如果此代码以任何方式破坏任何内容,我不承担任何责任。
如果有人想更新/合并这些脚本,那没问题。这些只是为了解决我的问题而制作的,他们这样做只是想我会分享它们。
I was having a problem with this too. I have Link2SD on my phone, but the ext4 partition on my SD card corrupted, so I reformatted, but all of the linked files were still in the /data/app folder. So I created a script to delete all broken links, and ran into the same problem as you, the app manager said they were still installed! so I made another script to fix that, using the pm program on your phone.
heres my code to remove broken links from the app folder:
and heres my code to uninstall apps that have no apk:
copy these files to your phone, and run them with no arguments to see what they find, or add fix onto the end (fixmissing.sh fix) to make them fix what they find. Run at your own risk, and back up your files. I am not responsible if this code in any way wrecks anything.
If anyone wants to update/merge these scripts together, thats fine. these were just made to fix my problem, and they have done so, just thought I'd share them.
我相信该应用程序在 SD 卡上创建的任何文件都不会被删除。
I believe any files the app has created on the sdcard would not be deleted.
还有另一种方法 - 像真实设备一样使用模拟器 -
在模拟器中找到该应用程序并将其向上拖动以将其卸载。
There is another way - using the emulator like a real device -
locate the app in the emulator and drag it up to uninstall it.