Preface
This article implements a Python script that can be used to bulk unload the App on the emulator or physical machine and clear the LogCat cache.
Android friends, simulators or mobile phones often have a lot of debugging of the demo, for the mobile phone is OK, but for the simulator, it is possible to cause the debugging speed and startup Speed drop. And the App in the simulator one delete is also very troublesome. With the ADB command, we can do a lot of things, including the batch operation simulator or the APP on the phone. Of course, it includes the delete operation. With the Python script and the ADB shell command and the CMD window with AS, we can condense all this into a command line.
Core code
# Delete all the Appdef Delallapp (): print ' Start delete all your apps in your Phone or Simulator ' Os.popen (' adb wait-for-dev Ice '); Corename = raw_input ("Input your app package Corename:") oripackages = Os.popen (' adb shell pm list Packages {name} '. Format (Name=corename)); # list all PackageName-oripackage in oripackages:deletepackage = Oripackage.split (': ') [1] os.popen (' adb uninstall ' + deletepackage); Print Deletepackage + "is deleted" # removes all the specific Appdef listallpackage () that you specify for the package name: i = 0 os.popen (' adb wait-for-device '); Corename = raw_input ("Input your app package Corename:") oripackages = Os.popen (' adb shell pm list Packages {name} '. Format (Name=corename)); For oripackage in oripackages:deletepackage = Oripackage.split (': ') [1] Print str (i) + ":" + deletepackage DELETELIST.A Ppend (deletepackage) i + = # delete specified appdef Deleteapp (number): Os.popen (' adb uninstall ' + deletelist[number]); print ' delete ' + Deletelist[number] + "Success" # clear LogCat Cache def clearlogcat (): print ' Start clEar Logcat Buffer in your Phone or Simulator ' Os.popen (' adb wait-for-device '); Os.popen (' adb logcat-c '); print ' Logcat is cleared success '
Effect implementation
How to use
Make sure your as is able to use the ADB command
Configure the Python 2.7 environment (there should be no problem with it)
Locate the current script path input in the CMD provided by as: python unistall.py
Follow the command prompt to enter the core keywords of the package you want to remove the App from, such as: com.example.RxCacheDemo
, enter example (everyone as this configuration should be the same)
After the above steps are completed, you will be prompted to delete the success or not.