1

I recently decided to port my Android Studio project over from ant to gradle. This project was actually created with gradle at first, but at the time I wasn't up for figuring out all the differences between gradle and ant, so I manually stripped everything gradle from the project and compiled it with ant up until now.

I decided to go back to gradle, but instead of converting the existing project, I instead just created a fresh new gradle project and imported all the modules/pasted all of the code/libs in from the old ant one.

I was able to get everything to work, except when I compile I get the following error:

oh no

I never got this method when compiling with ant, and like I said above, the code, modules, and libs are the same. When I first made this question, I actually made a mistake and entered in all of the jars in my libs folder twice. Here is the original list of dependencies:

libs

If you look closely the first line is dir=libs include=[*.jar]. I also added all of those jars below as well (I was dumb and just didn't see that was a line). So now my dependencies list looks like this:

better

This is a lot less, and I figured it would solve the problem. However when I tried loading the app onto my device, the same error occurred.

One thing I thought could be the case is that many of my modules rely on the same android-support-v4 library that the main app is dependent on. I think I reference that maven repo 3-4 times in the different modules (and the main app itself). Is there a more efficient way of doing this, or does the compiler know to not include a different instance of that v4 support library for each dependency?

Another noteworthy discovery: I'm getting a handful of errors which look like this:

warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$4) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

When I run gradlew assembleDebug (this specifically is the process which throws the error). I searched around and it seems like this is just a warning which can be ignored, but I imagine the dozen or so of these I get could have an impact. The full log can be seen here: http://pastebin.com/m4ASGQfC

Summary: I am getting the Dex 65536 error, which indicates that the project has too many method, but I only get this error since upgrading from ant to gradle, before I did that everything worked fine.

Thanks!

JMRboosties
  • 15,500
  • 20
  • 76
  • 116
  • Run **`gradle dependencies`** to get a report of everything Gradle is trying to pull in. – CommonsWare May 15 '14 at 21:19
  • I assume you mean ./gradlew dependencies? The command gradle is not recognized by the terminal, and when I looked on Android's gradle guide I didn't see a mention of adding it to the path. Anyways, here is the result of that: http://pastebin.com/7T5Vs720 Didn't really show much. Sorry for the ignorance, can you describe what you mean (assuming what I tried was wrong)? – JMRboosties May 15 '14 at 21:30
  • "I assume you mean ./gradlew dependencies?" -- only if you are using **`gradlew`**. I don't recommend it. "Didn't really show much" -- more accurately, it didn't show *anything*, which doesn't make much sense to me. It should have given a list reminiscent of your screenshot, though with transitive dependencies also listed. – CommonsWare May 15 '14 at 21:32
  • You probably need to either install a local version of gradle and/or add it to your PATH. – Code-Apprentice May 15 '14 at 21:33
  • Yea, I used gradlew because **./gradle dependencies** and **gradle dependencies** didn't work. I searched for running gradle and found this link: http://developer.android.com/sdk/installing/studio-build.html#buildCmd which is where I came up with gradlew. I'll look around for the right way to call gradle dependencies, I'm assuming I need to add it to my path. – JMRboosties May 15 '14 at 21:35
  • **`gradlew`** is the standard recommendation. I'm more security-conscious, and the blind use of **`gradlew`** raises security concerns. For your purposes, assuming that your **`gradlew`** came when you created the project, **`gradlew`** is fine. – CommonsWare May 15 '14 at 21:37
  • So now the problem is why my dependencies is not listing a full list like I see when I look in my project structure window. I'm all ears there, I'll keep playing around with it in the meantime. – JMRboosties May 15 '14 at 21:39
  • So I found a problem which I thought would solve this, but didn't. I will update the question to reflect this. – JMRboosties May 15 '14 at 21:41
  • @CommonsWare doing **./gradlew app:dependencies** gave me a list. It gave me a lot of lists actually, for compile, debug, releaseCompile, and more, but all of the types which had entries looked the same: http://pastebin.com/9969qWm0 – JMRboosties May 15 '14 at 22:41
  • Yes, it is correctly handling the dependencies and is only pulling in one copy of the support JAR, which is what I wanted to confirm. – CommonsWare May 15 '14 at 22:46
  • Something I noticed in that list though, is that the jars I include in the libs folder are NOT included in it. My code doesn't raise any errors though, so it seems that it is still including them, just not listing them as a dependency via this command. Another thing I should add: cleaning the project, rebuilding the project, and even making the project does not throw any errors, only compiling it onto a device. – JMRboosties May 15 '14 at 22:48
  • I tried getting rid of some libraries but only managed to fix the problem by using Proguard in the debug build. – aleb Jul 08 '14 at 10:26
  • possible duplicate of [Unable to execute dex: method ID not in \[0, 0xffff\]: 65536](http://stackoverflow.com/questions/15209831/unable-to-execute-dex-method-id-not-in-0-0xffff-65536) – aleb Jul 08 '14 at 10:27

0 Answers0