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)

Hi Team,

I’m facing the below issue during the cordova build, kindly help me. Thanks.

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)

E:\billing\Android\Projects\test>cordova build
ANDROID_HOME=E:\billing\Android\Sdk
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_40

Welcome to Gradle 6.1!

Here are the highlights of this release:

  • Dependency cache is relocatable
  • Configurable compilation order between Groovy, Java & Scala
  • New sample projects in Gradle’s documentation

For more details see Gradle 6.1 Release Notes

Starting a Gradle Daemon (subsequent builds will be faster)

Task :wrapper

BUILD SUCCESSFUL in 5s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Exception in thread “main” java.lang.NullPointerException
at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:84)
at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:4
0)
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:63)
cmd: 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:4
0)
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:63)
Picked up _JAVA_OPTIONS: -Xmx512M

E:\billing\Android\Projects\test>gradle -v
Picked up _JAVA_OPTIONS: -Xmx512M


Gradle 6.1

Build time: 2020-01-15 23:56:46 UTC
Revision: 539d277fdba571ebcc9617a34329c83d7d2b259e

Kotlin: 1.3.61
Groovy: 2.5.8
Ant: Apache Ant™ version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_40 (Oracle Corporation 25.40-b25)
OS: Windows 7 6.1 x86

Please help me,
Thanks in Advance.

Hi @mysangithub

What’s the contents of your gradle/wrapper/gradle-wrapper.properties file?

Hi Sterling Greene,

Have a Good Day!,

I have fixed the issue finally by myself. The issue is due to the multiple java reference in the environment variables.

I have removed all the jdk installed, also removed all the java reference from environment variable.
And re installed the jdk1.8.161 (as most of the people used this version in 8 series) and updated the environment variable accordingly.

Please find the packages and versions finally working for me.

Node.js version 13.8 with npm 6.13.6,
Cordova version 9 (installed globally),
Android SDK Latest with target upto android -25 & build tools.
Java JDK - 1.8.161.
Gradle - 2.14.1_all

Environment variable references:-
Node.js (installed in c drive),
Android SDK path,
Android SDK platforms path,
Android SDK build path,
Android SDK tools path,
Java JDK path (installed in c drive),
Java jre path (available along with jdk path in c drive),
Gradle path (extracted in c drive/gradle/),
Gradle zip path.

And I didn’t made any reference to Cordova in environment variable.

Also, updated the project/platforms/android/cordova/lib/builders/GradleBuilder.js with the distribution URL pointing to local gradle zip file. (http link also working).

Created a hello world app with android@6.0.0 and successfully build the apk.

Thanks
Santhosh

sorry but I also have the same problem as this. But with shorter log.
I set the JAVA_HOME,JDKLIB during runtime.
For reference Below is my batch file content:
set EXE4J_JAVA_HOME=%cd%\jdk-14.0.0.36-openj9less\bin*
** set JAVA_HOME=%cd%\jdk-14.0.0.36-openj9less*

** set ANDROID_HOME=E:\androidplatformtools\andrdstd\sdk**
** set JDKLIB=“%cd%\jdk-14.0.0.36-openj9less\lib”**
** set PATH_TO_FX=“%cd%\javafx-sdk-14\lib”**
** set APACHE_COMMON_MATHS=“%cd%\common_maths\commons-math3-3.6.1.jar”**
** set APACHE_COMMON_MATHS_up=“%cd%\common_maths”**
** set Fast_Utils=“%cd%Fastutils\dsiutils-2.6.5.jar”**
** set Fast_Utils_up=“%cd%\Fastutils”**
** set APACHE_COMMON_IO=“%cd%\commons-io-2.6\commons-io-2.6.jar”**
** set GRADLE=“E:\Coding\androidstdcode\legacy\gradle-6.3\bin”**
** PATH = %EXE4J_JAVA_HOME%;%PATH%;%GRADLE%**
** set CLASSPATH= .%PATH_TO_FX%;%APACHE_COMMON_IO%;%APACHE_COMMON_MATHS%;%Fast_Utils_up%;%cd%**
** cmd /k**

Then I type gradlew android which produces

Exception in thread “main” java.lang.NullPointerException

  •    at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:74)*
    
  •    at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:40)*
    
  •    at org.gradle.wrapper.Install.createDist(Install.java:40)*
    
  •    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)*
    
  •    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:58)*
    

which is shorter than op but, still an error.

The local directory at where batch start:

gradle (file not the one used in path because inside have the wrapper folder instead of gradle(versionno))
src
my bat
build.gradle
gradlew
gradlew.bat

Thank you it’'s my first time building an apk originally built desktop app,since now most people are forced to stay at home decided to burn my time.
Any help is welcomed.^^