问题
When I try to run my Android project on Eclipse ADT, I see this in the Console:
[2017-03-24 15:34:41 - Dex Loader] Failed to load C:\Users\jaimemontoya\android-sdks\build-tools\26.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!
I am using Eclipse Neon.2 Release (4.6.2):
This is the package configuration I have as seen from the 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?
回答1:
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!
回答2:
I had the same error today and happened to find your post. And after several attempts, I found deleting 26 rc1 Build-tools can help solve the issue.
回答3:
Reading the accepted answer at Got "unsupported class file version 52.0" after including a module to a project gave me the hint I needed to find the solution.
I ended up with this Android SDK installation:
Then I switched from "jre1.8.0_121" to "jre7", and also changed my Compiler compliance level from "1.8" to "1.7":
My App finally compiled successfully.
回答4:
Work Eclipse and Android Studio together
> add this to the project.properties of your project:
> sdk.buildtools=25.0.2
回答5:
Eclipse ADT no more support. So Google break backward compatibility with remove two classes from dx.jar
.
You can easy fix it.
- Go to your sdk folder. Navigate to
dx.jar
from latest build-tools.
For examplebuild-tools\28.0.3\lib
- Open
dx.jar
in any zip archiver.
I use WinRAR. - Navigate to path
com\android\dx\command
inside archive.
Here you not see filesDxConsole$1.class
andDxConsole.class
. - Now navigate to
dx.jar
for25.0.3
or before. - Again navigate to
com\android\dx\command
inside this archive.
Here you see filesDxConsole$1.class
andDxConsole.class
. - Copy it from old
dx.jar
to newdx.jar
. I just drop its from one WinRAR window to another.
All done. Now you can use new dx.jar
with Eclipse ADT.
This solution better from replace dx.jar
, because you can use new version of the dx.jar
.
You need do this steps on every update build-tools.
回答6:
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.
回答7:
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\27.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$2.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).
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.
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.
回答8:
I used previous version build-tools 25.0.0.
It seems Eclipse doesn't want to work with the newer versions. Though Android Studio recognizes them without problems.
回答9:
I had the same Error.
In Android SDK Manager I uninstalled all
Android SDK Build-Tools.
Then I installed only
Android SDK Build-Tool Version 25.0.3.
After this I can build my Applications.
回答10:
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.
回答11:
first run the android SDk manager download android SDK build-tools 25.0.3
open project.properties file and add this line
(sdk.buildtools=25.0.3)
at last restart Eclipse
回答12:
Copy the dx.jar from 25.0.3 to 26.0.2 lib directory.
回答13:
in eclipse preferences -> java -> installedJREs add x86 installed version of Java jre path and select it then restart eclipse
回答14:
I experienced this while using Microsoft Visual Studio 2017 to build a Xamarin Forms Solution that had a Xamarin Android project.
Error was Unable to access jar file C:\Program Files (x86)\Android\android-sdk\build-tools\25.0.3\lib\dx.jar
After confirming that the file required was actually absent, what I did was to open up the Android SDKs and Tools window, went to the tools tab, expanded the 'Android SDK Build tools' node, unchecked the 'Android SDK Build-Tools 25.0.3', applied the changes.
This got this build tool uninstalled.
Afterwards, I had it checked and applied. This got it re-installed with all the necessary files.
Build was then successful.
回答15:
I was having the same problem (with Eclipse 4.3 - Kepler). Solution was to open SDK manager, uninstall "Android SDK Build-tools [rev. 28]" (or whichever you're using that is above rev. 25), install "Android SDK Build-tools" rev. 24.0.3 (in my case, otherwise version 25 should work too I believe) and restart Eclipse. This did the job in my case.
The thing is, latest Android SDK build tools don't work with older versions of Eclipse (or at least this is how I understand it).
Hope it helps!
回答16:
This might help.the third answer
Add this in your build.gradle
:
buildToolsVersion "25.0.2"
来源:https://stackoverflow.com/questions/43009679/unknown-error-unable-to-build-the-file-dx-jar-was-not-loaded-from-the-sdk-fold