Java 未知错误:无法构建:未从 SDK 文件夹加载文件 dx.jar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43009679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder
提问by Jaime Montoya
When I try to run my Android project on Eclipse ADT, I see this in the Console:
当我尝试在 Eclipse ADT 上运行我的 Android 项目时,我在控制台中看到:
[2017-03-24 15:34:41 - Dex Loader] Failed to load C:\Users\jaimemontoya\android-sdks\build-tools.0.0-preview\lib\dx.jar
[2017-03-24 15:34:41 - CouponClub] Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!
[2017-03-24 15:34:41 - CouponClub] 未知错误:无法构建:未从 SDK 文件夹加载文件 dx.jar!
I am using Eclipse Neon.2 Release (4.6.2):
我正在使用 Eclipse Neon.2 Release (4.6.2):
This is the package configuration I have as seen from the Android SDK Manager:
这是我从 Android SDK Manager 看到的包配置:
What I understand from that error is that it failed to load dx.jar because it is trying to load it "from the SDK folder". The message even uses an exclamation mark to say that! What SDK folder is it referring to? I thought in this case "C:\Users\jaimemontoya\android-sdks" would be considered an SDK folder. Do you know where it is expecting to find the "dx.jar" file?
我从该错误中了解到它无法加载 dx.jar,因为它试图“从 SDK 文件夹”加载它。该消息甚至使用感叹号来表示!它指的是什么SDK文件夹?我认为在这种情况下“C:\Users\jaimemontoya\android-sdks”将被视为一个 SDK 文件夹。您知道在哪里可以找到“dx.jar”文件吗?
采纳答案by Jaime Montoya
Reading the accepted answer at Got "unsupported class file version 52.0" after including a module to a projectgave me the hint I needed to find the solution.
在将模块包含到项目中后,阅读Got“unsupported class file version 52.0”中接受的答案给了我找到解决方案所需的提示。
I ended up with this Android SDK installation:
我最终完成了这个 Android SDK 安装:
Then I switched from "jre1.8.0_121" to "jre7", and also changed my Compiler compliance level from "1.8" to "1.7":
然后我从“jre1.8.0_121”切换到“jre7”,并将我的编译器合规级别从“1.8”更改为“1.7”:
My App finally compiled successfully.
我的应用程序终于编译成功。
回答by user7768257
I was also having the same problem however, i decided to uninstall the eclipse and then delete the whole folder...you can do so by clicking on Help (while on eclipse) ---> then 'about eclipse' ---> then 'installation details' and uninstall, after deleting the whole folder i re-downloaded eclipse and all the SDKs from the SDK download manager And it began working for me again. Hope it works out.
但是,我也遇到了同样的问题,我决定卸载 eclipse 然后删除整个文件夹...您可以通过单击帮助(在 eclipse 上)---> 然后是“关于 eclipse”--->然后“安装详细信息”并卸载,删除整个文件夹后,我重新下载了 eclipse 和 SDK 下载管理器中的所有 SDK,它又开始为我工作了。希望它能奏效。
回答by Vancent
I had the same error today and happened to find your post. And after several attempts, I found deleting 26 rc1 Build-toolscan help solve the issue.
我今天遇到了同样的错误,碰巧找到了你的帖子。经过多次尝试,我发现删除26 个 rc1 Build-tools可以帮助解决问题。
回答by Foobnix
None of the answers helped me only my decision fixed the situation:
没有一个答案对我有帮助,只有我的决定解决了这个问题:
Fix is to copy
修复是复制
android-sdk/build-tools/25.0.3/lib
to the folder
到文件夹
android-sdk/build-tools/26.0.1/lib
Now all works great!
现在一切都很好!
回答by user8681709
This might help.the third answer
这可能会有所帮助。第三个答案
Add this in your build.gradle
:
将此添加到您的build.gradle
:
buildToolsVersion "25.0.2"
回答by Abdulmoiz Esmail
Copy the dx.jar from 25.0.3 to 26.0.2 lib directory.
将 dx.jar 从 25.0.3 复制到 26.0.2 lib 目录。
回答by karim fereidooni
in eclipse preferences -> java -> installedJREs add x86 installed version of Java jre path and select it then restart eclipse
在 eclipse 首选项 -> java -> installedJREs 添加 x86 安装版本的 Java jre 路径并选择它然后重新启动 eclipse
回答by Paras Santoki
I have same problem in eclipse. I was copy "lib" folder from "F:\Androidsdk\build-tools\19.1.0\". Paste this folder in "F:\eclipsesdk\build-tools\27.0.2\". Remove "lib64" folder from "\build-tools\27.0.2\". Means you have copy "lib" folder from old build-tools version and paste into latest build-tools version folder.
我在日食中有同样的问题。我从"F:\Androidsdk\build-tools\19.1.0\"复制了 "lib" 文件夹。将此文件夹粘贴到"F:\eclipsesdk\build-tools\27.0.2\" 中。从"\build-tools\27.0.2\" 中删除 "lib64" 文件夹。意味着您已从旧的构建工具版本复制“lib”文件夹并粘贴到最新的构建工具版本文件夹中。
回答by Vektorsoft
After struggling with this error for several hours I found some clues of this puzzle you maybe find useful.
在为这个错误苦苦挣扎了几个小时之后,我发现了这个谜题的一些线索,你可能会觉得有用。
First I found a log in the current workspace where the errors were logged, particularly:
首先,我在记录错误的当前工作区中找到了一个日志,特别是:
!ENTRY org.eclipse.andmore 4 0 2017-12-21 06:05:34.764
!MESSAGE Failed to load C:\Program Files (x86)\Android\android-sdk\build-tools.0.2\lib\dx.jar
!STACK 0
java.lang.ClassNotFoundException: com.android.dx.command.DxConsole
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.andmore.internal.build.DexWrapper.loadDex(DexWrapper.java:109)
at org.eclipse.andmore.internal.sdk.Sdk.getDexWrapper(Sdk.java:806)
at org.eclipse.andmore.internal.build.BuildHelper.executeDx(BuildHelper.java:777)
at org.eclipse.andmore.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:274)
at org.eclipse.andmore.internal.project.ExportHelper.run(ExportHelper.java:376)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
So there is something else aside the Failed to load.
所以除了无法加载之外还有其他东西。
I checked dx.jar and I verified DxConsole class is not there. Even more, DxConsole is not also in 26.0.3. However, I found it in 25.0.3 (I just opened the jar using any binary tool and looking for DxConsole. Even it is a Zip file, DxConsole filename can't be compressed so it would be easy to search for).
我检查了 dx.jar 并验证了 DxConsole 类不存在。更重要的是,DxConsole 不在 26.0.3 中。但是,我在 25.0.3 中找到了它(我只是使用任何二进制工具打开 jar 并寻找 DxConsole。即使它是 Zip 文件,DxConsole 文件名也无法压缩,因此很容易搜索)。
Summing up, those users saying that replacing dx.jar for an older dx.jar version are right to some point.
-You will need first close Eclipse (otherwise you will have errors trying to replace the jar file)
- Be careful what dx.jar version you are using for replace (25.0.3 worked for me)
- make backup of {android sdk}\build-tools\27.0.2\lib\dx.jar and replace it with {android-sdk}build-tools\25.0.3\lib\dx.jar
-This issue is likely to happen with anybody having 26.0.x version
-This worked for me , afterwards I had a 'No DEX file found' but I guess this is not related. Otherwise, I'll improve this answer.
总而言之,那些说将 dx.jar 替换为旧 dx.jar 版本的用户在某种程度上是正确的。
- 你需要先关闭 Eclipse(否则你会在尝试替换 jar 文件时出错)
- 小心你用于替换的 dx.jar 版本(25.0.3 对我有用)
- 备份 {android sdk}\ build-tools\27.0.2\lib\dx.jar 并将其替换为 {android-sdk}build-tools\25.0.3\lib\dx.jar
-这个问题很可能发生在任何拥有 26.0.x 版本的人身上
-这对我有用,之后我有一个“未找到 DEX 文件”,但我想这无关紧要。否则,我会改进这个答案。
Few additional things to being noticed:
需要注意的一些其他事项:
-I'm using Eclipse Neon 3.
-My proyect is using Android 4.2.2 (API 17) and Android (API 10) so the problem seems to be unrelated with my project. I believe there are clever people out there that will figure it out what is going on.
-我正在使用 Eclipse Neon 3。 -
我的项目正在使用 Android 4.2.2 (API 17) 和 Android (API 10) 所以这个问题似乎与我的项目无关。我相信那里有聪明的人会弄清楚发生了什么。
回答by mortalis
I used previous version build-tools 25.0.0.
我使用了以前的版本build-tools 25.0.0。
It seems Eclipsedoesn't want to work with the newer versions. Though Android Studiorecognizes them without problems.
这似乎Eclipse中不想要的工作与新版本。尽管Android Studio可以毫无问题地识别它们。