简体   繁体   English

为 Android 运行 dx 或 d8 工具时出错

[英]Error while running dx or d8 tool for Android

I am trying to build Android apps manually from the command line.我正在尝试从命令行手动构建 Android 应用程序。
But, whenever I am running dx.bat command which is located inside the Android SDK build-tools directory, I am always getting an error.但是,每当我运行位于 Android SDK build-tools 目录中的 dx.bat 命令时,我总是收到错误消息。 Whichever option I give, I always get the same error.无论我给出哪个选项,我总是得到同样的错误。 While running dx --help , I got this error :运行dx --help ,出现此错误:
-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.当我使用 Android Studio 时,我没有遇到任何此类问题。 What mistake am I doing and how to get the dx.bat file to work right?我在做什么错误以及如何让 dx.bat 文件正常工作?

I had solved this issue by editing the dx.bat file.我已经通过编辑 dx.bat 文件解决了这个问题。
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) :我刚刚更改了 dx.bat 文件的这一行(最后一行):

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

to this :对此:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM