3

I'm trying to deploy an android build for the app. But below error occurs in the process.

May be the issue is in gradle. But "gradle -v" command executes on cmd successfully and views gradle version. But I separately downloaded gradle files and set path variables to use gradle.

ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\intern\AppData\Local\Android\Sdk\ (DEPRECATED)

Subproject Path: CordovaLib
Subproject Path: app
Exception in thread "main" java.lang.NullPointerException
        at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:84)
        at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:40)
        at org.gradle.wrapper.Install.createDist(Install.java:44)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
C:\Users\intern\Desktop\ionic\MyIonicProject\platforms\android\gradlew: Command failed with exit code 1 Error output:
Exception in thread "main" java.lang.NullPointerException
        at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:84)
        at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:40)
        at org.gradle.wrapper.Install.createDist(Install.java:44)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

I'expecting to get a successful build on my android device which is connected to PC but it ends with a NullPointException error in a gradle file .

Ichigo Kurosaki
  • 3,765
  • 8
  • 41
  • 56
Hasitha
  • 67
  • 2
  • 9

1 Answers1

2

You haven't set

ANDROID_SDK_ROOT=undefined (recommended setting)

you have to set ANDROID_SDK_ROOT

Setup Your root

  • Tools -> Android SDK Tools

  • Tools -> Android SDK Platform-tools

  • Tools -> Android SDK Build-tools

Where is android_sdk_root? and how do I set it.?

https://github.com/apache/cordova-android/issues/670

Chanaka Weerasinghe
  • 5,404
  • 2
  • 26
  • 39
  • i am also having same issue below are my settings Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=D:\AndroidSDK (recommended setting) ANDROID_HOME=D:\AndroidSDK (DEPRECATED) Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio [ERROR] An error occurred while running subprocess cordova. cordova.cmd build android exited with exit code 1. – Dexter Oct 30 '19 at 06:18
  • i already installed Android studio with native java created a app and deployed on to device it is running perfectly but with ionic facing issue – Dexter Oct 30 '19 at 06:19
  • have you set graddle path – Chanaka Weerasinghe Oct 30 '19 at 06:24
  • allways for your help – Chanaka Weerasinghe Nov 07 '19 at 10:18
  • @ORBIT Hey have a look at this. According to this its not a must to set the value of ANDROID_SDK_ROOT . But anyway I tried then ANDROID_HOME disappears and error shows up about not setting up ANDROID_HOME . https://developer.android.com/studio/command-line/variables – Hasitha Nov 08 '19 at 14:14