December 28, 2015

How to get the Google Play User Agent for a given device

The Finsky useragent (not the same as the Chrome useragent) is used to determine app/device compatibility.

This article is mostly obsolete now
If you need the useragent of the Playstore app, simply use DummyDroid.

I get support requests every other day about Raccoon not being able to find an download certain apps from Google Play. In many cases this is because Raccoon has to mimic an Android device and the device it mimics by default is not compatible with the app in question. The good news is: Raccoon can be configured to act like a different device, the bad news is that this is going to be a bit techy.

Play determines app compatibility by the hardware profile bound to your GSF (Google Services Framework) ID and by the Useragent string of the market client. Why not just by GSF ID? Because this one is created when you sign in with Play for the first time and doesn’t account for OS updates you may (or may not) be receiving. In fact, it even seems like Play relies on the Useragent exclusively these days.

Ok, so how do you get the User Agent String for your device? Sadly it’s hardcoded in the Play client app, so there is no convenient way to get it, meaning you have to construct it by hand, using the following template (one line, no line breaks):

Android-Finsky/%s (versionCode=%d,sdk=%d,device=%s,hardware=%s,product=%s,build=%s:%s)

The %s and %d are placeholders that you have to fill in with the right values. In the following, I’ll assume that you are familiar with ADB and how to execute shell commands. So in order of appearance:

Android-Finsky/%s

dumpsys package com.android.vending | grep versionName

versionCode=%d

getprop ro.build.version.sdk

sdk=%d

getprop ro.build.version.sdk

device=%s

getprop ro.product.device

hardware=%s

getprop ro.hardware

product=%s

getprop ro.build.product

build=%s:%s

getprop ro.build.id
getprop ro.build.type

The whole thing then goes into credentials.cfg in your archive’s directory, prefixed with “useragent=”.

In case you are using a custom ROM, an Amazon Kindle or any other device without the GApps package installed, dumpsys naturally won’t give you the version information for the com.android.vending package. Just try “3.10.10” as the versionName and “8016010” as the versionCode (values taken from a 2012 Nexus 7).