Tag Archives: Windows

Automating Google Play Store reports with ‘gsutil’ and Windows PowerShell

Why (feel free to skip)

As Android developer I have various mobile devices (phones, tablets, watches) with all Android version starting 4.0 (Ice Cream Sandwich, API 14) up to Android 12 (L, API 31). Those devices accompanied by very detailed test scenarios help me ensure best possible user experience 🙂

Android test devices

As Android developer I have various mobile devices (phones, tablets, watches) with all Android version starting 4.0 (Ice Cream Sandwich, API 14) up to Android 12 (L, API 31).

When prepping release for an app, all test cases for that particular app are performed on each device. For each Android version I keep track of active installs and user rating. Applying that data in the test scenario. This helps me focus more on particular set of for ex. unhappy users running specific OS version.

Below is a screenshot of a test scenario for one of my apps: GSM Signal Monitor & SIM Card Info.

GSM Signal Monitor & SIM Card Info test scenario

GSM Signal Monitor & SIM Card Info test scenario

Each Android version has number of active installs and rating. Going to Google Play Store dev console and collecting this information by hand is somehow tedious job, so I decided to automate it using ‘Google Cloud Storage Util‘ and a bit of Windows PowerShell scripting.

How

Our task is to fetch Google Play store monthly reports for app installs and ratings by OS version, filter them and get data that can easily be copy pasted in the ‘Active Installs‘ tab of the test scenario.

1. Cloud Storage bucket ID

Google Play reports, beside dev console can also be accessed via Google Cloud Storage bucket associated with your developer account. You can go to “Download reports”, pick the report type you want and select “Copy Cloud Storage URI” next to it.

Google Play Cloud Storage URI

The url will look like this

gs://< bucket_id >/stats/installs/

where < bucket_id > will be your actual developer account cloud storage bucket. Remember this bucket id. We will be using it later.

2. Install gsutil

Google provides GSUtil for using cloud storage from the command line. Head over to https://cloud.google.com/storage/docs/gsutil_install#expandable-1 and follow the installation instructions.

We will be utilizing the gsutil.cmd assuming that the script is available in system PATH.

Next we need to authorize gsutil to access our cloud storage data. Follow the instructions on how to Authenticate stand-alone gsutil. For ‘project-id’ use the project ID of the app you want to get reports for. I’m interested in retrieving reports for GSM Signal Monitor & SIM Card Info app so I will be using it’s Cloud Storage project id.

Cloud Storage Project ID

If everything is setup correctly, opening command prompt and typing “gsutil help” should produce result similar to the screenshot below:

gsutil help command output

3. PowerShell magic 🙂

Script below will fetch installs and ratings reports from Google Play for specific app for the current month. Will get the last date available in the install report, filter both install and rating reports by ‘last available date’ and strip the reports from rows / columns we are not interested in. It will iterate over the active installs and will try to match installs with the ratings.

Replace $bucketId and $appPackageName with your cloud storage bucket id and your app package name.

Reports fetched from Google Play and the final output will be saved in the current working directory.

Upon execution you will get a report for your app active users/ratings by Android version, based on the data for the last date available in the install report nicely opened in your default text editor.

Script output: Active users and ratings.

P.S: Enable column selection mode in Notepad++ to get only the numbers. Use the arrow keys or your mouse while holding Shift + Alt.

P.S1: More info on how to retrieve various reports with gsutil here.

Feel free to modify the script to suit your reporting needs 🙂

Git checkouts fail on Windows with “Filename too long error: unable to create file”

Cause

According to the msysgit wiki on GitHub and the related fix this error, Filename too long, comes from a Windows API limitation of file paths having 260 characters or fewer.

Resolution

To resolve this issue, run the following command from GitBash or the Git CMD prompt (as administrator):

git config --system core.longpaths true

This will allow file paths of 4096 characters.

Copying Cyrillic URLs in Google Chrome and Firefox

Using Google Chrome, I encountered strange bug affecting the copying and pasting of cyrillic urls.

When pasting, the non ASCII characters in the Url are converted to Punycode.

Performing some tests revealed that the same behaviour is present also in Firefox.

Punycode produced by Google Chrome and Firefox

Punycode produced by Google Chrome and Firefox

Doing some research led me to Issue 68718, unfortunately marked as WontFix stating:

Links on Wikipedia itself are a red herring, as comment 50 notes -- they're escaped in the page source.  The actual issue here is demonstrated by the link in comment 0.  We escape URLs when copying them.  This behavior matches Firefox 4 (by default) and Safari 5, though not IE9.

We added this behavior on  issue 2820  to fix a variety of problems in languages like Japanese.  Because those problems resulted in users unable to navigate to the pasted links, whereas this issue seems to be solely about cosmetics (in that escaped URLs are ugly and hard to read), preserving that behavior change seems like the more important thing to do.

Workarounds

Few things can be done if this issue is affecting your day to day usage of Google Chrome…

  • Before copying the URL add any character at the end of it, then erase it. After this operation the copied URL will preserve its structure not producing punycode when pasted.
  • Use the COPY URL extension.
  • Use a different browser. Microsoft Edge on Windows and Safari on OSX are producing the expected results.

Featured Image: https://wallpapercave.com/w/A7ZAUTz

TortoiseGIT Disconnected: No supported authentication methods available ( server sent: publickey )

After migrating to SSH authentication for my Bitbucket repo ( one of the reasons for doing that was to be able to mirror my repo on my home server, article on that topic coming soon ), the TortoiseGIT windows client stopped working. It was unable to do pulls and pushes and all other functionallity related to connecting to the remote GIT. Android Studio and other IDE’s and tools I use on a daily basis, including git command line client were working properly.

Untitled1

TortoiseGIT uses Pageant (part of the PuTTY toolset) to manage it’s authentication keys. Because I have already generated the public / private key pair using ssh-keygen all I needed to do was make Pageant aware of them.

For this Puttygen (part of the PuTTY toolset) should be used.

Untitled4

pass

Load the key in Puttygen (you will be prompted for password during the loading process), leave the default settings. If the import was successful you will get a message telling you so.

success

Then click ‘Save private key’ button and save your private key in putty default ppk format. Fire up Pageant and load your newly created key.

Untitled6

Now pulls, pushes and all other functionallity related to connecting to the remote GIT should work as expected.

Untitled7

NOTE: Pageant should be started prior to using TortoiseGIT, else you will get the same error message again.

Hyper-V: How to change screen resolution in CentOS / Red Hat Enterprice Linux virtual machine

I’m thinking of doing a switch to GNU/Linux as my desktop OS yet again! (My last GNU/Linux desktop experience lasted for 5 years, then back to Windows.) This time giving CentOS 7 a try.

Why CentOS? I particularly like that, it’s one of the few GNU/Linux distributions out there providing LTS, which means I will have a stable development machine for at least 2 – 3 more years.

Making a decision to migrate or stay with Windows among other things is testing various aspects of the distribution such as how things works out of the box, installing various development tools / applications required for my area of work, etc..

For testing, CentOS 7 was installed on Hyper-V virtual machine. What I didn’t liked after the installation was the screen resolution that the machine was set to (1152×864) with now way of chaining it either from KDE System Settings or Hyper-V virtual machine properties.

After a bit of digging I learned that there is a frame buffer driver for Hyper-V and that CentOS unlike other distributions I have worked with, provides a tool called grubby for managing grub.cfg. It’s way easy to work with grubby than editing “/etc/default/grub” for example and running update-grub.

To set the desired screen resolution under Hyper-V. Open a terminal, and su. Then execute:

grubby --update-kernel=ALL --args="video=hyperv_fb:1280x1024"

and reboot the system.

NOTE: Replace 1280×1024 with the desired screen resolution.

See grubby man page if you need further info on what the a bought line does.