# Exception in thread "main" java.lang.NullPointerException

**URL:** <https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430>\
**Category:** ionic-v1\
**Created:** [October 10, 2016, 11:57am UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430 "2016-10-10T11:57:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Egea](https://avatars.discourse-cdn.com/v4/letter/e/8e7dd6/32.png) [@Egea](https://forum.ionicframework.com/u/Egea)\
**Post date:** [October 10, 2016, 11:57am UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430/1 "2016-10-10T11:57:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tesnep](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tesnep/32/104372_2.png) [@tesnep](https://forum.ionicframework.com/u/tesnep)\
**Post date:** [December 13, 2016, 12:43am UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430/2 "2016-12-13T00:43:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![afgsystem](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@afgsystem](https://forum.ionicframework.com/u/afgsystem)\
**Post date:** [December 13, 2016, 10:38pm UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430/3 "2016-12-13T22:38:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SMEYIO](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@SMEYIO](https://forum.ionicframework.com/u/SMEYIO)\
**Post date:** [January 10, 2017, 2:35pm UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430/4 "2017-01-10T14:35:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tesnep](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tesnep/32/104372_2.png) [@tesnep](https://forum.ionicframework.com/u/tesnep)\
**Post date:** [January 12, 2017, 3:30am UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430/5 "2017-01-12T03:30:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bb065](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@bb065](https://forum.ionicframework.com/u/bb065)\
**Post date:** [January 19, 2017, 10:42pm UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430/6 "2017-01-19T22:42:26Z")

</div>

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](http://stackoverflow.com/questions/29874564/ionic-build-android-error-when-download-gradle) 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

---

<div class="post-metadata">

**Author:** ![ShlomoAran](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@ShlomoAran](https://forum.ionicframework.com/u/ShlomoAran)\
**Post date:** [July 11, 2017, 9:44am UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430/7 "2017-07-11T09:44:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Planck663](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@Planck663](https://forum.ionicframework.com/u/Planck663)\
**Post date:** [May 16, 2018, 8:26am UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430/8 "2018-05-16T08:26:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Hasitha550](https://avatars.discourse-cdn.com/v4/letter/h/f1d935/32.png) [@Hasitha550](https://forum.ionicframework.com/u/Hasitha550)\
**Post date:** [October 29, 2019, 1:06pm UTC](https://forum.ionicframework.com/t/exception-in-thread-main-java-lang-nullpointerexception/66430/9 "2019-10-29T13:06:23Z")

</div>

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