如何卸载APK(或执行ADB命令)运行或调试前自动? [英] How to uninstall APK (or execute adb command) automatically before Run or Debug?

查看:228
本文介绍了如何卸载APK(或执行ADB命令)运行或调试前自动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我需要运行/调试它在Android的工作室之前,每次卸载应用程序。因为我需要重新创建数据库之前,我跑\调试应用程序。我知道我可以运行在/数据/数据​​/ [程序包]命令亚行卸载[程序包]在终端以清除文件。但它不是方便的方式,如果我每次都执行该命令。我希望亚行卸载命令可以自动当我点击运行\调试按钮来执行。

解决方案
  1. 在Android的Studio中,单击下拉列表,以运行按钮的左边,然后选择编辑配置...
  2. 点击下的Andr​​oid应用程序,并在常规选项卡,找到标题推出前
  3. 单击+按钮,选择运行外部工具,点击弹出窗口中的+按钮。
  4. 在给予一定的名称(如亚行卸载)和描述,并在节目类型亚洲开发银行:和卸载<您-包名称> 的参数:。 确保新项目被选中当你在弹出的窗口中单击OK。

请注意:如果你没有ADB在PATH环境变量,给的完整路径亚洲开发银行计划:字段(例如/家庭/用户/安卓/ SDK /平台工具/ ADB)

Now I need to uninstall the App every time before Run/ Debug it in Android Studio. Because I need to re-create the database before I run \debug the app. I know I can run the command "adb uninstall [package_name]" in terminal to clear the files under /data/data/[package_name]. But it's not convenient way if I have to execute the command every time. I hope the "adb uninstall" command can be executed automatically when I click "Run" \ "Debug" button.

解决方案

  1. In Android Studio, click the drop down list to the left of Run button, and select Edit configurations...
  2. Click on app under Android Application, and in General Tab, find the heading 'Before Launch'
  3. Click the + button, select Run external tool, click the + button in the popup window.
  4. Give some name (Eg adb uninstall) and description, and type adb in Program: and uninstall <your-package-name> in Parameters:. Make sure that the new item is selected when you click Ok in the popup window.

Note: If you do not have adb in your PATH environment variable, give the full path to adb in Program: field (eg /home/user/android/sdk/platform-tools/adb).

这篇关于如何卸载APK(或执行ADB命令)运行或调试前自动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆