Exception in thread "main" java.lang.NullPointerException

Hi, i have a problem when i try to build my application. This is what i do:

λ ionic build android
Running command: “C:\Program Files\nodejs\node.exe” C:\Users\D644503\Desktop\IONIC\simple-login\hooks\after_prepare\010_add_platform_class.js C:\Users\D644503\Desktop\IONIC\simple-login

add to body class: platform-android

ANDROID_HOME=C:\android-sdk-windows

JAVA_HOME=C:\Program Files\java\jdk1.8.0_101

Exception in thread “main” java.lang.NullPointerException
at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:77)
at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:43)
at org.gradle.wrapper.Install.createDist(Install.java:43)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)

Error: cmd: Command failed with exit code 1 Error output:
Exception in thread “main” java.lang.NullPointerException
at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:77)
at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:43)
at org.gradle.wrapper.Install.createDist(Install.java:43)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)

Can anybody help me?

2 Likes

I have the same issue in my work pc. I am going to test with JDK 1.7 to see if that makes any difference.

EDIT
Changed to JDK 7 and that didn’t work. Ran command prompt as an administrator. made no difference. Gradle Version is 2.13-all. I am going to try with 2.2.1-all with both versions of JDK.

EDIT
Nope. Still does not work.

I’m investigating for this mistake, i’m following.

Is this issue resolved? Even I am facing the same issue.

Nope. Gave up. A Cordova plugin prevented using ant so I had to use Gradle. Just could not get around a remote fetch in the end.

Hello! I had exactly the same issue the last days and weeks.
I’m behind a corporate proxyy and in the end I solved it in that way;
As recommend in this Post I changed in the platforms\android\cordova\lib\builders\GradleBuilder.js file the distributionUrl like the following:
var distributionUrl = 'https\://services.gradle.org/distributions/gradle-2.14.1-all.zip';
(which was before)
var distributionUrl = 'http\\://services.gradle.org/distributions/gradle-2.14.1-all.zip';

removing one ‘’ and changing from http to https solved the problem for me and it starts with donwloading

I had an error that the build could not find the gradle.
So I installed gradel and set the “path” to the gradle’s bin folder.
Now I recieve this error (Exception in thread “main” java.lang.NullPointerException)
But the fix that you suggested doesn’t work, because it already has the gradle (so it doesn’t need to download it).

I had this error for a long time, although my line numbers were different (77 was 84) but I assume this is a different version of Gradle.

It turned out that my environment variables weren’t set correctly. (They were set on my admin account, not my normal account).

The solution for me was to add a GRADLE_HOME User variable, and add %GRADLE_HOME%\bin to my path.

I’m facing the same issue. Is there anyone who found a solution ?

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)
[ERROR] An error occurred while running subprocess cordova.

    cordova.cmd build android exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.