compiling Jars and add them to android project

有些话、适合烂在心里 提交于 2019-12-04 13:35:50

Ok after a long research, i think that i know what is the problem, however i don't know how to workaround it yet.

Symptoms : compiling large jar and or several jars, cause to eclipse to crash, when it doesn't crash error message : trouble writing output: opcode == null , Conversion to Dalvik format failed with error 2 .

Cause : DX is unable to process more than it can contain in a string of 16bit, thus, there is no way to include(at least not in the mean time) more than the length of this string.

Result : unable to program complicated apps for Android as one APK.

Advice for android developers (i don't quite sure how you built it but): you can use arraylist for these strings, which each one of them writes itself in turn to classes.dex file, then, there will be no limit for writing code for one APK, and/or adding as many jars as the developer needs, this is an assumption, making it won't be easy but not too complicated too, definitly not to the ones who made Android, Agree ?

Workaround : sorry but i don't have a workaround yet, it took me some time to figure this problem, because the eclipse crashed and i didn't get the "opcode == null", error message so i thought that this is an eclipse issue, I will be glad to get second and third opinion on this one.

Once the JARs have been built then add them as External JARs...

In Eclipse select the 'Project' menu -> 'Properties' then 'Java Build Path'. Select the 'Libraries' tab then click the 'Add External JARs...' button then browse and add them.

I have had the same problem. There was lot of "Dx processing ..." messages in verbose output and it took about 3-4 minutes to build classes.dex(3.4 Mb). That was very slow and I felt a butthurt. Then I made a research and found out that the reason of the problem was in wrong eclipse JVM settings(eclipse.ini). BTW, I got this nasty config from some stackoverflow answer with more than 100 accepts.

Please make sure that eclipse.ini doesn't contains following line:


    CompileThreshold=5

I removed this line and now compilation takes ~10 sec!!! Also, now I use ParallelGC instead of G1GC in eclipse config because it's more stable and it doesn't crash my IDE.

So, your main task is to revise your eclipse.ini and get rid of all suspicious and experimental parameters.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!