Preparing Windows for Android App Development

IMPORTANT NOTES

  1. This tutorial contains very important information, please read slowly and carefully and follow the instructions completely. IF YOU SKIP ANY PART, YOU CAN'T RUN ANY APPS.
  2. Developing Android app is not simple, the most important part is to prepare your development environment properly first. These system requirements are for the mobile app (NOT for DB AppMaker), you must install them and make sure they works properly before using DB AppMaker to generate apps.
  3. The following steps might take some time but they will save you a lot of time afterwards. Make sure you go through all of them. More haste only results in less speed.

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).

First of all, please read the following for Ionic Framework carefully:

Above articles contain important information, PLEASE DO NOT SKIP! They explains what you need to develop apps, including:

After reading and installing above, double check the follows. Note that the following is NOT a summary of above, it is important points that we must reiterate and further explain to make sure you set up correctly.

 

Java Development Kit (JDK)

Install Java Development Kit (JDK) 8 or later.

Important You MUST install JDK 8. Unfortunately, Cordova is not compatible with the latest version of Java.

 

Gradle
  1. Download the latest Gradle distribution
  2. Unpack the Gradle distribution ZIP into C:\Gradle using an archiver tool of your choice.
  3. In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables. Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-6.3\bin. Click OK to save.

 

Android SDK

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.

  1. In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings
  2. In the window that appears, click the Environment Variables button,
    1. 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_231 (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.
    2. 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_231\bin (containing jarsigner.exe and keytool.exe, change the folder name to the actual one on your PC)
    3. Under System variables, press New..., add variable ANDROID_SDK_ROOT and set it to your SDK path, e.g. (substitute the paths with your actual paths)
      C:\Users\<user>\AppData\Local\Android\SDK
      Since some tools still use the deprecated ANDROID_HOME, you should add that also, press New..., add variable ANDROID_HOME and set it to your SDK path, e.g. (substitute the paths with your actual paths)
      C:\Users\<user>\AppData\Local\Android\SDK
    4. 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)
      %ANDROID_SDK_ROOT%\platform-tools (containing adb.exe)
      %ANDROID_SDK_ROOT%\build-tools\<version> (containing zipalign.exe, change <user> and <version> to the actual ones on your PC)
      %ANDROID_SDK_ROOT%\tools\bin (containing avdmanager.bat and sdkmanager.bat)

Read Environment variables for complete information.

 

Installing Google USB Driver

To test the generated apps directly on an Android mobile device, you need to download and install the Google USB Driver, see Android SDK above. 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. (The <android_sdk> folder is usually C:\Users\<user>\AppData\Local\Android\Sdk, you can verify with your File Explorer.)

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.)

Important

  1. 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 (e.g. C:\Users\<user>\AppData\Local\Android\Sdk\platform-tools). If connected, you'll see the device name listed as a "device", e.g.
  2. If the device is not detected, check your USB connection options on your device.

 

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. Follow the following tutorials and test:

Start a new app, it is recommended that you create it at where without permission considerations, e.g. D:\. From the command line or Windows PowerShell, enter:

ionic start myApp sidemenu --type=angular

(When you are asked about integrating your new app with Capacitor, enter N and press Enter.)

The the CLI will download and install many npm packages for the new app, this takes several minutes for the first time, please be patient and wait.

(After the download is done, you will be asked about creating free Ionic account, enter N and press Enter.)

Now you can use cd to change the current directory to the new project's folder:

cd myApp

To run the app on your Android device (make sure it is plugged in over USB and you can see it with adb devices as said above), run the following command one by one from the command line in the project's folder:

ionic cordova platform add android

ionic cordova run android --device

Ionic CLI will compile the app and run it on your Android device.

Again, the CLI will takes several minutes to complete this process for the first time, please be patient and wait.

This empty app does not do anything other than demonstrating the side menu. However, if this app runs successfully on your device, congratulations, your development environment is now properly set up. You may proceed to create your first app from a database by following Quick Start.

 

 

 ©2016-2021 e.World Technology Limited. All rights reserved.