I'm trying to use the package name and determine the apk path of an app to check if my app is installed in the device.

pathCmd = './adb shell pm path ' + packageName

pathData = os.popen(pathCmd,"r")

for pathInfo in pathData:

    print pathInfo 

    if not pathInfo:
        print "App not found on the device"

        print "App found on the device"

This doesn't give me the list of apps that are not installed. Any idea whats wrong with my script?

  • Before people vote to close, this doesn't seem to be a clear-cut development question. While it's true that he is developing a script, it's also an ADB question. It's essentially something you could do in bash or in a Windows batch. I'll let the community decide if this is off-topic or not.
    – dotVezz
    Dec 23 '13 at 23:59
  • Consider to accept your own answer if there is no other answer, and if it solved your problem, thanks.
    – Andrew T.
    Apr 27 '15 at 5:40

This did the trick guys.

pathCmd = './adb shell pm path ' + packageName
result = os.popen(pathCmd).read()
if result:
    print "App found on the device"
    print "App not found on the device"

This give system output as string and looks for string length to confirm the presence of an app in the device. Its usually an empty string that is received for a package name that doesn't exist in the device.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.