dg_no_9 dg_no_9 - 1 year ago 100
Bash Question

Android: How to Know if any application is already installed in android device using adb?

I've to install an android app with package name like "com.xyz.game" using adb.
I want to automate the process using shell script. The process will be like if app is already installed, uninstall it(with command adb uninstall com.xyz.game) and install using "adb install game.apk" otherwise simple "adb install game.apk".

How can I achieve this?

Answer Source


According to (also) correct answer below, try grep the result from pm list packages.

adb shell pm list packages | grep com.your.app.package


If the application is already installed and if you try to install the same app again, adb will return with an error - Failure [INSTALL_FAILED_ALREADY_EXISTS]. However, if you want to re-install the already installed app, then use -r parameter.


adb install -r game.apk
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download