18

I have 2 app versions - pro and lite. They are both already on the market at v1.01. I am trying to release v1.1 for both. This update includes SwawrmConnect integration in order to use their global leaderboards.

I should start off by saying I know I am not maintaining my code correctly. I have 2 completely separate apps and that share probably 90% of their code. I maintain them separately because after a week or 2 or 3 of failing to figure out how to do a library and share code, I gave up and just went this way with it.

SwarmConnect is the first jar I have used and had to make a library to two apps (see screenshot of file structure below).

Right now my lite version is working and is ready for release. I am now trying to get my pro version to where it needs to be for release. I am fairly certain all java/xml files are up to date and ready. When I went to run the pro version in the emulator, I get the below error:

[2013-04-18 11:24:41 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/swarmconnect/loopj/android/http/AsyncHttpResponseHandler;
[2013-04-18 11:24:41 - BibleTriviaPro] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/swarmconnect/loopj/android/http/AsyncHttpResponseHandler;

Things I've tried:

  • Clean/rebuild
  • Update Eclipse
  • Delete bin and gen folders
  • Restart Eclipse
  • Plus some other stuff

My file structure:

enter image description here

Could the problem be is I am trying to use SwarmConnect as a library for 2 projects (lite and pro)?

EDIT:

Below is the file structure for the lite version that is working perfectly. Compiles and runs on emulator.

enter image description here

Matt
  • 3,882
  • 14
  • 46
  • 89
  • you have added SwarmConnect twice. thats the problem – Sankar V Apr 18 '13 at 15:42
  • I have edited my opening post. You can see that my Lite version looks the same as my Pro version. Why would one work and the other not? I have the jars in their twice on my Lite version also and it works perfectly. – Matt Apr 18 '13 at 15:49
  • @Matt including a jar twice is sure to cause problems, no matter what: I don't trust what Eclipse is telling you unless you actually look at the build files yourself. – Kristopher Micinski Apr 18 '13 at 15:50
  • Ok, I can fix the lite version also then. If a jar should only be in the project once, where is the one place it should be? If I know that I can remove the other(s). – Matt Apr 18 '13 at 15:51
  • 1
    BibleTriviaPro has that little red cross attached. Since you're adding images of your Eclipse's layout, could you post an image of the Problems section as well? – DigCamara Apr 18 '13 at 15:53
  • @Matt You can add it to lite version once and pro version once but not twice on the same project – Sankar V Apr 18 '13 at 15:55
  • @DigCamara - you can see the file structure for BibleTriviaPro in the 1st screenshot. The red x is by the project name but it is no where else in the file structure. It just keeps posting the LogCat output that I have in the opening post. – Matt Apr 18 '13 at 16:01
  • @Matt I saw that. That's why I'm asking about the Problem's section which in my Java perspective in Eclipse can be found at the bottom. Sometimes Eclipse has a generic problem with your project which won't show up in a specific file, its way of telling you is by putting that little red cross on the project itself. – DigCamara Apr 18 '13 at 16:04
  • @DigCamara - oh, ok. I don't have that open by default. Do you know the exact name of that perspective? I would probably find it under either `Window > Open Perspective > ...` or `Window > Show View > ...` most likely. – Matt Apr 18 '13 at 16:10
  • Window>Show View>Problems – DigCamara Apr 18 '13 at 16:11
  • Turns out to be the same as I have in my opening post: `Description Resource Path Location Type Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/swarmconnect/loopj/android/http/AsyncHttpResponseHandler; BibleTriviaPro Unknown Android Packaging Problem`. – Matt Apr 18 '13 at 16:15

5 Answers5

37

Coincidentally I ran into the same issue just day before yesterday. Here's what I suggest you to do.

First and foremost make sure that you have a backup of all the jars presently residing in the 'Android Dependencies'/'libs' folder.

Now, lets fix the lite version first by following these steps.

  1. Remove all jar files except android-support-v4.jar from the 'Android Dependencies' folder under Project Explorer in Eclipse.

  2. Similarly remove all Jar files except android-support-v4.jar from the libs folder under Project Explorer in Eclipse.

  3. Now Right click on your project-> Select Properties-> Select Java Build Path-> Select Add External JARs. Add all the necessary jar files (just make sure you add a particular jar file only once).

Finally clean the project and build it. Now apply the same sequence of steps to the pro version. That should do it.

UPDATE:- In case you see Eclipse cribbing about some compile time errors after doing all this all you might have to do is to just fix those compile time errors by doing the necessary imports by pressing Ctrl+Shift+O.

[I assume that there's no linkage between the pro and lite versions of the project in terms of source dependencies etc.. what I mean to say basically they are totally independent.]

Hope this helps.

palacsint
  • 28,416
  • 10
  • 82
  • 109
Sdr
  • 1,090
  • 9
  • 8
  • You assume correct. The 2 apps are totally independent. I will do these steps and report back. – Matt Apr 18 '13 at 16:24
  • Sorry just added a quick update. It just flashed to me in case you run into a sticky situation. – Sdr Apr 18 '13 at 16:33
  • I had the project in the "Project" dependencies and the jar's in the libs. Clumsy. – Siddharth Jul 12 '13 at 07:04
  • 1
    Removed them all, added them again, all fixed. What a weird error :) – Ewald Dec 23 '13 at 09:53
  • Removed them all, added them again, all fixed. What a weird error :) – Ewald Dec 23 '13 at 09:57
  • Also, [this](http://stackoverflow.com/questions/19727915/android-dex-gives-a-bufferoverflowexception-when-building/19803777#19803777) might be a simpler solution. – Abhinav Jan 25 '14 at 05:43
  • Two different versions of the same library existing, caused error – Narendra Singh Jul 13 '15 at 13:13
  • Thanks. I had a project that was using a gradle dependency in Eclipse and even the instructions said to put it into libs, but putting it in lib and doing this finally resolved it. I only wish I had seen this earlier. – Abandoned Cart Jul 23 '16 at 19:39
2

I strongly suspect this is your problem

  1. Right click your project
  2. Look under the "Android" option
  3. In the lower pane look if "Swarm Connect" is present
  4. If not, add it (though I really suspect it already is there)
  5. Remove Swarm.jar from your libs directory

the reason being: when you add a library project to an Android project in Eclipse, it doesn't show up in your libs directory. I actually tried to add just the .jar file to a project and got told that that was the wrong approach (at least until API 14, I think).

My guess is, in your "non-pro" version you didn't link it in the project options and thus it still compiles correctly. Still, you should link it the way I just described to avoid problems when the library tries to access its own resources.

DigCamara
  • 5,540
  • 4
  • 36
  • 47
2

The above solution didnt work for me,All i had to do was add the jars in the libs folder externally and Uncheck Android private libraries under the order and export tab.

 right click--
             java build path--
                               order and export tab ->Uncheck Android private libraries 
                                   and add jars in the libs folder externally.

do the above steps. Dont know why this is happening.

Aniruddha K.M
  • 7,361
  • 3
  • 43
  • 52
0

I tried @Sriram's answer above. It didn't work.

Then I had to remove the libraries from the Project->Properties->Java Build Path->Libraries place and add the actual jar's (I needed both android-support-v4.jar and android-support-v13.jar) into libs folder of my project. Then it worked:

final structure

(note that there is no "Referenced Libraries" folder)

alexey
  • 453
  • 6
  • 15
-1

I got this error because I used the entire Android Development Kit installer (Eclipse plus SDK, dated 2/6/2013). The only way I was able to get rid of it was to uninstall all of that, and separately install Eclipse For Java Developers from eclipse.org, and the Android SDK only from the Android site. The Eclipse that comes with the kit has some funny ideas about where to include libraries from, not to mention vestigial pieces of c++ and gdb support.

Pierre
  • 114
  • 4