Install and configure Android cmdline SDK on windows
In this blog we will learn how to install and Configure Android SDK, I had used cordova before on widows 8 with android build tools, Yesterday I wanted to reconfigure it again on windows 10 but I got a lot of errors. at last I fixed the problems, lets share with you people so that you can install and configure it easily and build your cordova, phonegap or ionic apps easily.
We have to download 3 things
1- JAVA sdk from this link
2- Android cmdline sdk tools from this link
3- Gradle from this link downlod Binary-Only
After downloading you have to organize it in proper folder structure as below
Files Structure
1- Create a folder named C:\Android
2- Extract Android cmdline sdk zip file in Android folder, its folder name is cmdline-tools, rename it to tools. so the path sould look like below
C:\Android\tools\bin\sdkmanager.bat
3- Extract gradle to Gradle zip also in C:\Android, and rename the folder to gradle instead of Gradle-8.8.2
Installation
We have to install JAVA first, then Android tools, and then gradle and configure environment variables
1- Install JAVA
Install the download JAVA sdk, it is normal just next.
2- Install Android SDK tools
To install Android sdk tools have to make an environment variable called JAVA_HOME and point it to java installation directory 1 step beyond bin folder e.g. C:\Programe Files\JAVA\jdk-11.0.17
now open cmd and move to sdkmanager bin folder in our folder structure it will be: C:\android\tools\bin
now run below this command
1 |
sdkmanager --list |
it will show you installed and available packages.
we have to install 3 packages platform-tools, Android-platform and Build-tools. choose the latest stable version of these packages in available platforms, make sure you choosen same versions for all as I have choosen 31 in below packages.
Now run below commands one by one so that you can see if there is any error, in between it migh ask you to press Y/N you have to press Y
1 2 3 |
sdkmanager "platform-tools" sdkmanager "platforms;android-31" sdkmanager "build-tools;31.0.0" |
After successfully running these commands you might notice new folders have been created in c:\Android folder.
Create Environment Variables
Now we have to create some environment variable, we have already created JAVA_HOME
create below with specified paths
Variable Name | Path |
---|---|
ANDROID_HOME | C:\Android |
ANDROID_SDK_ROOT | C:\Android |
GRADLE_HOME | C:\Android\gradle |
Now go into path environment variable and add below entries
Path |
---|
%JAVA_HOME%\bin |
%ANDROID_HOME%\platform-tools |
%ANDROID_HOME%\cmdline-tools\tools\bin |
%ANDROID_HOME%\cmdline-tools |
%GRADLE_HOME%\bin |
This is all, now you should be able to build cordova or ionic app at your PC, you can check installed android sdk packages by running sdkmanager –list command and notice avaialble packages
java –version
javac –version
gradle –version
to confirm these are properly installed or not
Create and Build test app
create and build test app
lets create and build test cordova app and see the output, follow below commands
1 2 3 4 5 6 7 8 9 |
npm install -g cordova cordova create testapp cd testapp cordova platform add android cordova build |
All these commands will be taking some time but at end of execution of last command you will get path of built APK
Good luck with Configure Android SDK and happy apps development.
Comments