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?
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
adb install -r game.apk