Skip to content Skip to sidebar Skip to footer

Running Shell Script In Android Adb Shell

I'm trying to create a script to find and remove my app from the Android emulator through the adb shell. This is what I've got: adb shell ' cd data/app for app in com.mycompany.*.a

Solution 1:

You should not really go through the /data/app folder. If you want to uninstall multiple packages with names matching the com.mycompany pattern with a single adb command use:

adb shell "pm list packages com.mycompany | cut -c9- | xargs -n 1 sh /system/bin/pm uninstall"

Solution 2:

I'm still curious to know why my approach was "suboptimal" and what could I have done better?

Wild guess since I'm not familiar with adb shell but bash: Quotation. Variables can not be inside ticks '...$VAR' but "...$VAR". Anything inside ticks is taken "as is", i.e. literally:

echo'bundle name is $bundle'

vs.

echo"bundle name is $bundle"

Post a Comment for "Running Shell Script In Android Adb Shell"