androiddxandroid-d8

Error while running dx or d8 tool for Android


I am trying to build Android apps manually from the command line.
But, whenever I am running dx.bat command which is located inside the Android SDK build-tools directory, I am always getting an error. Whichever option I give, I always get the same error. While running dx --help, I got this error :
-Djava.ext.dirs=E:\.android\SDK\build-tools\29.0.2\lib is not supported. Use -classpath instead. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

When I had Android Studio, I didn't get any such problems. What mistake am I doing and how to get the dx.bat file to work right?


Solution

  • I had solved this issue by editing the dx.bat file.
    As mentioned in the error

    -Djava.ext.dirs=E:\.android\SDK\build-tools\29.0.2\lib is not supported.  Use -classpath instead.
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    

    I had just changed this line of the dx.bat file (last line) :

    call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
    

    to this :

    call "%java_exe%" %javaOpts% -classpath "%frameworkdir%" -jar "%jarpath%" %params%