Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automated Installation of an .apk from the Google Play Store

I'm writing some end-to-end tests of an Android-TV-App using Python and my own implementation of the ADB-Protocol. This works fine so far, I can send commands, get ui-dumps ect.

However, since the app is only available on the Google Play Store (I don't have access to any source code) and I want to update the version of the app every week, I'm wondering how I can do this using ADB.

I thought about following solutions:

  1. Send key events to open play store on the device and navigate to to the installation / update page of the app.
  2. Download the app somehow to the Testmachine and push it to the device by ADB.
  3. Use ADB to directly install a new version of the app on the device.

Whats "best practice" on this and how should i solve my problem?

like image 474
Tobias von Falkenhayn Avatar asked Nov 05 '18 15:11

Tobias von Falkenhayn


3 Answers

Here is how I would have done it.
1.First open the app page in playstore

adb shell am start -a android.intent.action.VIEW -d 'market://details?id=com.yourpackagename'

2.Then send touch on the install/update button.

adb shell input tap <x> <y> (Default: touchscreen)
like image 59
royatirek Avatar answered Oct 11 '22 14:10

royatirek


Download APK locally using Google Play Downloader via Command line and install it with adb.

$ gplaycli -s 'App Inspector'
Title                                           Creator            Size      Downloads                 Last Update  AppID                        Version   Rating  
App Inspector                                   Projectoria        895.04KB  100,000+ downloads        14 Jul 2019  bg.projectoria.appinspector  8         4.53    
...
$ gplaycli -d bg.projectoria.appinspector
$ adb install bg.projectoria.appinspector.apk 
Performing Streamed Install
Success
like image 41
ten0s Avatar answered Oct 11 '22 14:10

ten0s


The answer worked for me on one phone without problem.

adb shell am start -a android.intent.action.VIEW -d 'market://details?id=com.yourpackagename'

But on other phones it was not working, throwing an error. You can fix that error (will edit tomorrow with the exact error) by removing the single quote (') from the command:

adb shell am start -a android.intent.action.VIEW -d market://details?id=com.yourpackagename
like image 28
Nioooooo Avatar answered Oct 11 '22 15:10

Nioooooo