Exception in thread "main" java.lang.NullPointerException


#1

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

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.


#3

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


#4

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


#5

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.


#6

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


#7

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


#8

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.