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?
Call the below function appInstalledOrNot() with the package name of the app installed on the ANDROID Device as a string parameter. This function returns true if the app is installed otherwise returns false. super . onCreate(savedInstanceState);
Step 1: Open https://play.google.com/store in your web browser. Step 2: Type the name of the app in the search bar to look for the app.
Have your phone connected when you type adb, then type adb devices, and it should lust your phone with serial number.
[Update 2]
Without using grep
adb shell pm list packages [your.package.name]
as mentioned in the below answer
[Update]
According to (also) correct answer below, try grep the result from pm list packages.
adb shell pm list packages | grep com.your.app.package
[Original]
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.
Ex:
adb install -r game.apk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With