0
votes

Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=C:\Users\Rpwebapps\AppData\Local\Android\sdk (recommended setting) ANDROID_HOME=C:\Users\Rpwebapps\AppData\Local\Android\Sdk (DEPRECATED) Cannot read property 'length' of undefined [ERROR] An error occurred while running subprocess cordova.

    cordova.cmd build android exited with exit code 1.

onic:

Ionic CLI : 5.2.7 (C:\Users\Rpwebapps\AppData\Roaming\npm\node_modules\ionic) Ionic Framework : @ionic/angular 4.8.1 @angular-devkit/build-angular : 0.801.3 @angular-devkit/schematics : 8.1.3 @angular/cli : 8.1.3 @ionic/angular-toolkit : 2.0.0

Cordova:

Cordova CLI : 9.0.0 ([email protected]) Cordova Platforms : android 8.0.0 Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 4 other plugins)

Utility:

cordova-res : 0.6.0 native-run : not installed

System:

NodeJS : v10.15.3 (C:\Program Files\nodejs\node.exe) npm : 6.4.1 OS : Windows 10

where i am missing, Environment Variables also created (paths) any one help me out

JAVA_HOME JDK-location ANDROID_SDK_ROOT GRADLE_USER_HOME platform-tools tools (Android\Sdk\tools) add variables

ionic cordova build android

4

4 Answers

7
votes

Yes, as it says you no longer can use ANDROID_HOME variable. You have to set ANDROID_SDK_ROOT instead.

  1. Open control panel
  2. Then go to System
  3. Then go to Change Environment Variables of the User
  4. Then click create a new environment variables
  5. Create a new variable named ANDROID_SDK_HOME
  6. Set its value to your Android directory C:\Users\Rpwebapps\AppData\Local\Android\sdk
1
votes

In case setting Environment variable is not resolving problem, you will need to install Gradle and set its environment variable. Installing Gradle is very easy. You can get information at https://gradle.org/install/ Windows user, do this activity with cmd run as administrator. Mac/Linux user have to do sudo.

Always remember, After you do Environment variable settings as suggested above, Please start another cmd and try your required command there.

0
votes

You need to setup environmental variable under "Path", just add your Android SDK path in that. Along with it define each as below -

Windows Env variables

ANDROID_SDK_ROOT - location of your android SDK folder
ANDROID_HOME - location of your android SDK folder
JAVA_HOME - Location of your JDK folder
PATH - Locations where programs could be located
PATH Should Include
%ANDROID_SDK_ROOT%\emulator
%ANDROID_SDK_ROOT%\tools
%ANDROID_SDK_ROOT%\tools\bin
%ANDROID_SDK_ROOT%\platform-tools
%ANDROID_SDK_ROOT%\build-tools
%JAVA_HOME%\bin

C:\Program Files\nodejs
C:\Users<your username>\AppData\Roaming\npm

you can also refer to the video - https://www.youtube.com/watch?v=nQ498PINsws

0
votes

In linux just change ANDROID_HOME to ANDROID_SDK_ROOT in your ~/.bashrc

where before was:

export ANDROID_HOME="/{path}/android-sdk-linux"

now is:

export ANDROID_SDK_ROOT="/{path}/android-sdk-linux"

Don't forget source it: $ . ~/.bashrc after edition.


ANDROID_SDK_ROOT:
Sets the path to the SDK installation directory. Once set, the value does not typically change, and can be shared by multiple users on the same machine. ANDROID_HOME, which also points to the SDK installation directory, is deprecated.

ref: https://developer.android.com/studio/command-line/variables#envar