34

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!

enter image description here

I am using Eclipse Neon.2 Release (4.6.2):

enter image description here

This is the package configuration I have as seen from the Android SDK Manager:

enter image description here

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?

Jaime Montoya
  • 6,915
  • 14
  • 67
  • 103
  • 1
    If you see the last screenshot I included in the question, it says: "SDK Path: C:\Users\jaimemontoya\android-sdks". So C:\Users\jaimemontoya\android-sdks is definitely my SDK folder. Where exactly could it be trying to find the dx.jar file? C:\Users\jaimemontoya\android-sdks\dx.jar did not make sense to me of course but I just tried it too and obviously it did not work either. – Jaime Montoya Mar 24 '17 at 22:21
  • 1
    If I rename my folder so that instead of C:\Users\jaimemontoya\android-sdks\build-tools\26.0.0-preview\lib\dx.jar I have C:\Users\jaimemontoya\android-sdks\build-tools\26.0.0-preview\lib2222222\dx.jar, I see the same error message: "[2017-03-24 16:30:03 - CouponClub] Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!" So it failed to load C:\Users\jaimemontoya\android-sdks\build-tools\26.0.0-preview\lib\dx.jar, but I wonder why. – Jaime Montoya Mar 24 '17 at 22:34
  • 1
    It seems to be trying to find it here: C:\Users\jaimemontoya\android-sdks\build-tools\26.0.0-preview\lib\dx.jar. I am trying to figure out why it is failing to load it. – Jaime Montoya Mar 24 '17 at 22:38
  • 1
    Possible duplicate of [Android ADT error, dx.jar was not loaded from the SDK folder](https://stackoverflow.com/questions/5228453/android-adt-error-dx-jar-was-not-loaded-from-the-sdk-folder) – laffuste Jul 02 '17 at 12:10

16 Answers16

29

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!

Foobnix
  • 719
  • 5
  • 7
19

Eclipse ADT no more support. So Google break backward compatibility with remove two classes from dx.jar.
You can easy fix it.

  1. Go to your sdk folder. Navigate to dx.jar from latest build-tools.
    For example build-tools\28.0.3\lib
  2. Open dx.jar in any zip archiver.
    I use WinRAR.
  3. Navigate to path com\android\dx\command inside archive.
    Here you not see files DxConsole$1.class and DxConsole.class.
  4. Now navigate to dx.jar for 25.0.3 or before.
  5. Again navigate to com\android\dx\command inside this archive.
    Here you see files DxConsole$1.class and DxConsole.class.
  6. Copy it from old dx.jar to new dx.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.

Enyby
  • 4,162
  • 2
  • 33
  • 42
  • @itzo Then you do something wrong. Described steps allow me stay use Eclipse even for build-tools `28.0.3`. This works for me also on `28.0.2`. – Enyby Feb 26 '19 at 14:11
  • Thanks, excellent way to still use Eclipse ADT for Android projects, it works perfectly ! – PGibouin Jun 28 '19 at 08:14
  • Perfect, In my work is still using Eclipse, good job – Zaha Mar 11 '21 at 12:23
  • This should be the accepted answer, because it explains the root cause of the issue. Yes, there are still people out there using Eclipse+ADT to build very old Android apps. – WebViewer Nov 24 '22 at 15:41
13

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.

Vancent
  • 477
  • 5
  • 16
  • Thank you for sharing your answer/solution Vancent. I ended up using Android Studio and abandoning Eclipse, but in case I try Eclipse again and have the same issue I will try your solution. Hopefully other people can try it too and confirm if it works for them. – Jaime Montoya Jun 05 '17 at 18:01
  • 1
    I had 26 rc2 Build-tools which I deleted, But my issue is still there. – Ishara Amarasekera Mar 30 '18 at 17:45
  • @IsharaAmarasekera Which version of Build-tools do you have? And it seems to be there only in Eclipse, for latest version doesn't seem to be supported in Eclipse according to android official. – Vancent Mar 31 '18 at 02:19
  • @Vancent This issue occurred to me in 26.0.3 when I removed that to see if that fixed it, the error moved to 26.0.2 and 26.0.1 respectively. Now the maximum I have is 25.0.3 and the issue is no longer there. As you mention, perhaps the latest versions are not supported in Eclipse. – Ishara Amarasekera Mar 31 '18 at 12:42
10

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:

enter image description here

Then I switched from "jre1.8.0_121" to "jre7", and also changed my Compiler compliance level from "1.8" to "1.7":

enter image description here

enter image description here

My App finally compiled successfully.

Community
  • 1
  • 1
Jaime Montoya
  • 6,915
  • 14
  • 67
  • 103
  • 1
    In another computer it was not working even after following the steps from this answer. It was until I uninstalled everything in the "Tools" and "Tools (Preview Channel)" folders using the "Android SDK Manager", and then only installed the three items that correspond to "Rev. 25.2.5, 25.0.4, and 19.1", that the error was fixed and it allowed me to compile. – Jaime Montoya Mar 27 '17 at 18:13
9

Work Eclipse and Android Studio together

> add this to the project.properties of your project:
> sdk.buildtools=25.0.2
Ahmad Aghazadeh
  • 16,571
  • 12
  • 101
  • 98
3

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.

Vektorsoft
  • 181
  • 1
  • 5
3

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

user1324491
  • 147
  • 4
2

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.

  • I tried on another computer and I get exactly the same error. – Jaime Montoya Mar 26 '17 at 03:58
  • 1
    But do you understand why uninstalling and then installing Eclipse again fixed the issue for you? I installed the entire environment on a different computer and I consistently experienced the same issue. – Jaime Montoya Mar 27 '17 at 07:40
2

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.

mortalis
  • 2,060
  • 24
  • 34
  • I abandoned Eclipse long ago and I have been working with Android Studio. I used Eclipse only for the purpose of migrating the code from Eclipse to Android Studio. Using the deprecated Eclipse plugins for Android development in 2018 is like trying to use Windows XP. I know it was a very successful operating system for many years but it is official unsupported and deprecated. You must do everything you can to try to move to Android Studio. It is official, Eclipse is deprecated for Android development, and Google wants developers to use Android Studio. They are only supporting Android Studio. – Jaime Montoya Jan 10 '18 at 15:08
1

Copy the dx.jar from 25.0.3 to 26.0.2 lib directory.

Abdulmoiz Esmail
  • 425
  • 4
  • 15
1

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.

Paras Santoki
  • 821
  • 11
  • 26
  • Doesn't sound like a smart idea to do things by hand when the managers already do that for you. – Loïc Faure-Lacroix Dec 21 '17 at 06:14
  • If you start messing with what the managers does by itself. You may end up having to do what the managers does automatically manually all the time. For example the managers might keep track of checksum of the files and as soon as you change things they installed or remove things... you end up with errors like above. Something is missing or not where it's supposed to be and the tool you use fail to actually do its job. Which is make things work. – Loïc Faure-Lacroix Dec 21 '17 at 08:19
1

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.

Ingo
  • 5,239
  • 1
  • 30
  • 24
1

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.

Android SDKs and Tools Window

David Jiboye
  • 511
  • 8
  • 19
0

in eclipse preferences -> java -> installedJREs add x86 installed version of Java jre path and select it then restart eclipse

-1

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!

Betalord
  • 109
  • 7
-3

This might help.the third answer

Add this in your build.gradle:

buildToolsVersion "25.0.2"
Sushin Pv
  • 1,826
  • 3
  • 22
  • 36