How to create a dex with D8.bat

578 Views Asked by At

I used to create dex file with dx.bat like this :

"c:\SDKs\android\build-tools\32.0.0\dx.bat" --dex --output=C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp\classes.dex C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp\obj.zip

How to do the same with d8.bat?

2

There are 2 best solutions below

0
Alex Lipov On

Creating DEX file using d8 can be achieved using:

d8 --output <output-folder> <input-files>

In your case, the following is an equivalent:

c:\SDKs\android\build-tools\32.0.0\d8.bat --output C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp C:\Dev\MagicFoundation\Alcinoe\Tools\AddRJavaToClassesDex\tmp\obj.zip
0
Shawlaw On

To anyone who is using d8.bat with OpenJDK-11, if you encounter the error when running d8.bat:

-Djava.ext.dirs=${PathToAndroidSDK}\build-tools${BuildToolVersion}\lib is not supported. Use -classpath instead.

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

You can edit d8.bat with a text editor, replacing the code -Djava.ext.dirs="%frameworkdir%" in last line to -classpath "%frameworkdir%" to fix the error.