Author Archives: Vladimir Paskov

Git: How to remove submodule

Quick tip on how to remove Git submodule.

  1. Remove the relevant line from the .gitmodules file
  2. Delete the relevant section from .git/config (if any)
  3. Run
    git rm --cached path_to_submodule

    (without trailing slash)

  4. Commit and delete the now untracked submodule files.

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 πŸ™‚

Moving Files from one Git Repository to Another, Preserving History

Once upon a time all my Android apps and VMSoft related stuff were part of one big BitBucket git repository along with an issue tracker. This was a good idea when being an Android dev was just a hobby for the weekends and not my primary job.

Enough rambling πŸ™‚ , this blog post is about moving files from one git repository to another and preserving your history.

Our goal is to move a single directory from one big Git repository to it’s own repository, we would like to preserve the commits history for that specific directory also.

In this example our big repo willΒ  be called A and our new repo that will host it’s own subset of files will be calledΒ B

First filter the files from the big repoΒ (A) by leaving only the ones you need:

git clone < repo A url >
cd < repo A directory >

Remove the “origin”

git remote rm origin

and filter A by < directory_to_move >. This action will go trough all the history and files and remove anything that’s not in < directory_to_move >.
More info on the inner workings of git filter-branch here.

git filter-branch --subdirectory-filter <directory_to_move> -- --all

filter-branch will leave you with the contents of < directory_to_move > in the root of repository A. Commit the changes and we can continue with the next step.

git add .
git commit

Moving to the new repository

Link repo A with repo B. The command below will make repository A branch of repository B.

git remote add repo-A-branch <git repository A directory>

Pull from the branch allowing unrelated histories

git pull repo-A-branch master --allow-unrelated-histories

and finally remove repo-A-branch

git remote rm repo-A-branch

That’s it, you now have your files in a new repository while preserving commits history.

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.

Every opacity value hex code

I often work with HEX colors and want to apply some alpha to them.

Calculating the exact alpha HEX value is tedious job so here it is: the complete list of every possible opacity value in HEX

100% β€” FF
99% β€” FC
98% β€” FA
97% β€” F7
96% β€” F5
95% β€” F2
94% β€” F0
93% β€” ED
92% β€” EB
91% β€” E8
90% β€” E6
89% β€” E3
88% β€” E0
87% β€” DE
86% β€” DB
85% β€” D9
84% β€” D6
83% β€” D4
82% β€” D1
81% β€” CF
80% β€” CC
79% β€” C9
78% β€” C7
77% β€” C4
76% β€” C2
75% β€” BF
74% β€” BD
73% β€” BA
72% β€” B8
71% β€” B5
70% β€” B3
69% β€” B0
68% β€” AD
67% β€” AB
66% β€” A8
65% β€” A6
64% β€” A3
63% β€” A1
62% β€” 9E
61% β€” 9C
60% β€” 99
59% β€” 96
58% β€” 94
57% β€” 91
56% β€” 8F
55% β€” 8C
54% β€” 8A
53% β€” 87
52% β€” 85
51% β€” 82
50% β€” 80
49% β€” 7D
48% β€” 7A
47% β€” 78
46% β€” 75
45% β€” 73
44% β€” 70
43% β€” 6E
42% β€” 6B
41% β€” 69
40% β€” 66
39% β€” 63
38% β€” 61
37% β€” 5E
36% β€” 5C
35% β€” 59
34% β€” 57
33% β€” 54
32% β€” 52
31% β€” 4F
30% β€” 4D
29% β€” 4A
28% β€” 47
27% β€” 45
26% β€” 42
25% β€” 40
24% β€” 3D
23% β€” 3B
22% β€” 38
21% β€” 36
20% β€” 33
19% β€” 30
18% β€” 2E
17% β€” 2B
16% β€” 29
15% β€” 26
14% β€” 24
13% β€” 21
12% β€” 1F
11% β€” 1C
10% β€” 1A
9% β€” 17
8% β€” 14
7% β€” 12
6% β€” 0F
5% β€” 0D
4% β€” 0A
3% β€” 08
2% β€” 05
1% β€” 03
0% β€” 00

How to use it:
#000000 – Black with ought opacity
#17000000 – Black with 9% opacity