Preparing Windows for Android App Development
Important Developing Android app is not simple, the most important part is to prepare your computer properly first. It might take a while but this will ensure smooth development and save you a lot of time afterwards. Please be patient, read and follow the instructions completely and carefully.
To prepare your Windows for developing Android apps, you must install all the components required to build and run the apps, including Java Development Kit (JDK) and Android Studio. Android Studio is the official Integrated Development Environment (IDE) for Android app development. The Android Studio is dependent on JDK (the JRE alone is not sufficient).
Installing Java Development Kit (JDK)
Install Java Development Kit (JDK) 8 or later.
Installing Android Studio for Windows
Download the latest version of Android Studio for Windows.
- If you downloaded an .exe file (recommended), double-click to launch it. If you downloaded a .zip file, unpack the ZIP, copy the android-studio folder into your Program Files folder, and then open the android-studio > bin folder and launch studio64.exe (for 64-bit machines) or studio.exe (for 32-bit machines).
- Follow the setup wizard in Android Studio and install any SDK packages that it recommends.
Read Install Android Studio for more information.
Update the IDE and SDK Tools
Once you installed Android Studio, it's easy to keep the Android Studio IDE and Android SDK tools up to date with automatic updates and the Android SDK Manager. Read Update the IDE and SDK Tools for details.
Open Android Studio, click Configure -> SDK Manager.
Go to SDK Platforms tab, select at least one Android SDK Platform packages you want to use, click Apply.
Go to the SDK Tools tab and make sure you have installed the following required tools:
Setting Environment Variables
Cordova's CLI tools require some environment variables to be set in order to function correctly, you may need to set them manually. The steps may vary depending on your installed version of Windows. Close and reopen any command prompt windows after making changes to see them reflected.
- Click on the Start menu in the lower-left corner of the desktop
- In the search bar, search for Environment Variables and select Edit the system Environment Variables from the options that appear:
- In the window that appears, click the Environment Variables button,
- Under System variables, add a variable named JAVA_HOME and enter your path, e.g. (substitute the paths with your actual paths)
C:\Program Files\Java\jdk1.8.0_111 (change the folder name to the actual one on your PC)
Note If you have also installed older versions of JDK (e.g. JDK 7), you should remove or rename the installed folder (e.g. C:\Program Files\Java\jdk1.7*) or Cordova may not detect your JDK version correctly.
- Under System variables, Select the PATH variable and press Edit..., add entries for the relevant locations to the PATH, e.g. (substitute the paths with your actual paths)
C:\Program Files\Java\jdk1.8.0_111\bin (containing jarsigner.exe and keytool.exe, change the folder name to the actual one on your PC)
C:\Program Files\Android\Android Studio\gradle\gradle-<version>\bin (containing gradle.bat, change <version> to the actual one on your PC)
- Under User variables, Select the PATH variable and press Edit..., add entries for the relevant locations to the PATH, e.g. (substitute the paths with your actual paths)
C:\Users\<user>\AppData\Local\Android\Sdk\build-tools\<version> (containing zipalign.exe, change <user> and <version> to the actual ones on your PC
Read Environment variables for complete information.
Installing Google USB Driver
To test the generated apps directly on an Android mobile device, you should also download and install the Google USB Driver. Firstly, you need to download the Google USB Driver package in the Android SDK. To do this:
- Open Android Studio > Configure > SDK Manager
- Under the SDK Tools tab, check the option Google USB Driver
- Click the Apply button
For more information about Google USB Driver, please read Get the Google USB Driver.
After installing the package, the files are downloaded and stored under the <android_sdk>\extras\google\usb_driver\ directory. The driver is not yet installed and you must perform the installation manually.
Using the SDK Manager helps you keep the driver up to date by notifying you when your current driver is out of date.
For installation information, read Install a USB Driver.
Setting up a Device for Development
To make your mobile device detectable by Windows, it is important to enable USB debugging on your device. (See Using Hardware Devices for details.)
- On Android 4.0 and newer, it's in Settings > Developer options. (On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.)
- When plugged in over USB, you can verify that your device is connected by opening a command prompt and executing
adb devices from your SDK platform-tools/ directory. If connected, you'll see the device name listed as a "device".
- If the device is not detected, check your USB connection options on your device. By default, your device will be in Charging only mode. If not, try to switch back to Charging only mode and try again.
Creating and Running Your First Android Project on Mobile Device
After installing Android Studio and the Google USB Driver and making sure your device is detected, you can proceed to verify if the configuration is correct by creating and running your first Android Application directly on your mobile device.
- In Android Studio, create a new project:
- If you don't have a project opened, in the Welcome to Android Studio window, click Start a new Android Studio project.
- If you have a project opened, select File > New Project.
- In the New Project screen, enter the following values:
- Application Name: "My First App"
- Company Domain: "example.com"
Android Studio fills in the package name and project location for you, but you can edit these if you'd like.
- Click Next.
- In the Target Android Devices screen, keep the default values and click Next.
The Minimum Required SDK is the earliest version of Android that your app supports, which is indicated by the API level. To support as many devices as possible, you should set this to the lowest version available that allows your app to provide its core feature set. If any feature of your app is possible only on newer versions of Android and it's not critical to the core feature set, enable that feature only when running on the versions that support it (see Supporting Different Platform Versions).
- In the Add an Activity to Mobile screen, select Empty Activity and click Next.
- In the Customize the Activity screen, keep the default values and click Finish.
After some processing, Android Studio opens and displays a "Hello World" app with default files.
- Make sure you have plugged in your mobile device to your PC with an USB cable,
- Make sure your PC is connected to internet,
- In Android Studio, click Run from the toolbar.
- In the Select Deployment Target window, select your device (make sure it is under Connected Devices and it is not detected as offline), and click OK.
After some building and deployment process (probably take a while), the blank app should be running in your mobile device.
If above works, your Windows is now properly set up. You may proceed to create your first app from a database by following Quick Start.