Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

shell

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?

like image 720
dg_no_9 Avatar asked Jan 03 '14 19:01

dg_no_9


People also ask

How do I know if an app is installed Android?

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);

How do I know if an application is installed or not?

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.

How do I know if adb is connected?

Have your phone connected when you type adb, then type adb devices, and it should lust your phone with serial number.


1 Answers

[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 
like image 144
Joel Fernandes Avatar answered Oct 20 '22 10:10

Joel Fernandes