Setup Windows for Android Development

Naimul Kabir
6 min readFeb 10, 2021

--

I will cover installing android studio, vs code, git, setting up auto-signing in git, improving android studio performance, making Gradle build time faster on Windows 10 and setting up the terminal.

Setup Android Development Environment on Windows 10

Debloat Your Windows 10

Just start with debloating your Windows 10 system. There are a lot of scripts online to make this simpler and easier for you. I use the script from Chris Titus, open a PowerShell, paste the command below and press enter, keep in mind that, this isn’t just a debloating script (GitHub Source), it will come handy later in this blog, keep this in mind.

iex ((New-Object System.Net.WebClient).DownloadString('https://git.io/JJ8R4'))

A new PowerShell window will appear, from there press Essential Tweaks and wait until you see an ‘Operations Complete’ dialogue, press ok, and if you love to, you can try other tweaks, like stopping background apps, and so on, but that’s your choice.

Install a package manager

Next, we are going to install Chocolatey, a package manager that makes installing programming tools, a lot simpler, and updating them a lot easier. To install chocolatey you can run the command below,

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1'))

or you can just, run the previous command again and press Install Chocolatey button, after the operations complete, tap on ok.

Install some necessary software

You can now install your favourite applications from here. I will install -

Android Studio comes with git, but we still need git in our command line, because, we know, you want to use git from your command line like a pro. To install git to ‘make vim use the regular Windows terminal instead of MinTTY terminal’, to ‘disable open GUI and open-shell integration ( “Git GUI Here” and “Git Bash Here” entries in context menus)’, let’s run our choco command.

choco install git.install — params “/WindowsTerminal /NoShellIntegration /GitAndUnixToolsOnPath /NoGitLfs /NoAutoCrlf”

Next, we will install Gpg4Win, (Here the purpose is to set up signed commit, to know more about the signed commit, head over to this blog) with the command -

choco install gpg4win

Setup git with auto signing

Thanks to Luca Bognolo, and his GitHub gist that helped me to finally successfully setup auto signing on Windows 10.

Verifed Commit on my GitHub

Generate your gpg keys by running this command below-

gpg --full-generate-key

If you don’t want to be nagged with constant password confirmation, keep the password blank (though it is not a very good idea).

After you have generated the keys, verify the installation by the command below.

$ gpg --list-secret-keys --keyid-format LONG
# /c/Users/Naimul/.gnupg/secring.gpg
# ----------------------------------
# sec 4096R/E870EE00B5D90537 2021-2-21 [expires: 2026-12-31]
# uid Naimul Kabir <kabirnayeem.99@gmail.com>
# ssb 4096R/F9E3E72EBBFDCFD6 2021-2-21

Now, we need to generate our revocation certificate. This command below will create a .rev file, that is needed to revocate a public key shared in a key server.

gpg --gen-revoke E870EE00B5D90537

And if you know how asymmetric encryption works, you may not want to share your private key, ever… So, we only send the public key.

gpg --send-keys E870EE00B5D90537

Now go to GitHub SSH and GPG settngs (here) from your browser, and add your public GPG key. If you can’t add the public key to your github, there might be some formatting issues, which can be resolved by coping the public gpg key and pasting it in a text editor, and saving it to open the file again and copy the file to paste it in the GPG key box.

Now we need to setup the git to use this signin key.

First add your name and email to your gitconfig by-

git config --global user.name "github_user_name"
git config --global user.email "github_noreply_user_email"

You can find your noreply email address in your GitHub settings under Email section (here) under the heading ‘primary email address’. It will look something like this ‘39023212+kabirnayeem99@users.noreply.github.com’.

Now, we will setup autosign for all commits, by

git config --global user.signingkey E870EE00B5D90537
git config --global commit.gpgsign true

Or if you don’t want to set this gloablly, you can use the command below-

git config user.signingkey E870EE00B5D90537
git config --global commit.gpgsign true

Now, we would set Git to use the custom gpg program, with this command, (it assumes that, you have selected the default location while installing GPG).

git config --global gpg.program "/c/Program Files (x86)/GnuPG/bin/gpg.exe"

Now go to “C:\Users\your_user_name\” and create a new directory named .gnugpg by running mkdir command and run the following command to solve issue where you you would have problems with making auto-signed commits from your IDE or other software.

mkdir .gnugpgecho 'no-tty' >> ~/.gnupg/gpg.conf

Installing Android Studio

Now we would install Android Studio using our favorite choco package manager, and pin it to taskbar.

choco install androidstudio --params '"/PinnedToTaskbar"'
Android Studio 4.1

Open Android Studio and follow the command on screen, as you will finish, we would proceed to make Android Studio a little bit faster.

Disable Virus Scanning to make build faaaster.

As pointed out in this Stack Overflow answer,

Go to Start > Settings > Update & Security > Windows Security > Virus & threat protection. Under Virus & threat protection settings, select Manage settings, and then under Exclusions, select Add or remove exclusions, and select Add > Folder, and select the folder mentioned below, by pasting the Path URL mentioned below in the File Explorer address bar and selecting the folder.

%USERPROFILE%\AndroidStudioProjects
%USERPROFILE%\AppData\Local\Android\SDK
C:\Users\YourUserName\AppData\Local\Google\AndroidStudio4.1

Tweaking Android Studio to make a little faster

Open Android Studio. Go to File -> Settings -> Plugins, and disable all the plugins below. Don’t worry, if you need them, you can always enable them.

Android APK Support

Android Games

Android NDK

App Links Assistant

Copyright

Coverage

CVS Integration

Editor Config

Fabric for Android Studio

Firebase (App Indexing, Services, Testing)

GitHub

Google (Cloud Tools Core, Cloud Tools for Android, Developer Samples, Login, Services)

Markdown Support

Mercurial integration

hg4idea

Settings repository

Subversion integration

Task management

Test recorder

TestNG-J

YAML

Make Terminal personal

oh-my-posh and Windows Terminal

Linux or mac veteran like me should know what ‘Oh-My-Zsh’ is, and here, I am going to present to you a plugin like that but for PowerShell and how to install it. And I am grateful to this blogpost for this guide.

Run your Windows Terminal as Adminastrator and write the commands below.

Install-Module oh-my-posh
Install-Module posh-git

Now let’s download some cool fonts, like that-

Invoke-WebRequest -Uri ‘https://github.com/powerline/fonts/archive/master.zip' -OutFile .\powerlinefonts.zip

Unzip like that-

Expand-Archive .\powerlinefonts.zip

And install like that-

.\powerlinefonts\fonts-master\install.ps1

Now open the powershell profile file

code $PROFILE

And paste the following line

Import-Module oh-my-posh
Import-Module posh-git
Set-Theme Agnoster

And save it.

Concluding…

Now set your execution policy to default again by

Set-ExecutionPolicy Default

This is all. You are now more or less ready to sit and start programming.

--

--

Naimul Kabir

Developer sharing insights on coding, platforms, and making tech easier!