【问题背景】小鸟本人现在Android平台上(Win7, Eclipse)移植一个开源的第三方项目A,问题多多啊,要了我的鸟命了!是这样的:A项目是基于JDK1.4的,我现在手里有源码;有项目本身所引用的jar,以及该项目编译并打包好的jar。我的想法是:将源码放到Android平台上重新进行编译。【问题之一】现在源码放到Android平台已经编译通过了,但是运行时老是报异常NoClassDefFoundError啊!经过查证,该异常的原因是引用第三方jar包的方法不正确,相关的类没有被打包的APK中。实际上,找不到定义的类在源码(我已导入Eclipse)、在jar包中都有,我就不明白,Eclipse为什么要到jar包中去找,而不在编译后的源码中找呢?【问题之二】我按照网上搜到的方法将需要的jar包导入到项目中,可以解决NoClassDefFoundError的问题。但是新的问题又出现了:项目A提供的jar包,有的可以顺利导入Eclipse,有的在导入的时候,编译时报错:Conversion to Dalvik format failed with error 1。那么,该怎么解决这个问题呢?      跪求大师们指点,如若提供有效的解决方案,小鸟愿意倾家荡产以报大师们的大恩大德!!!%>_<%……

解决方案 »

  1.   

    jar包导入出错,环境版本不同造成的,需要改一些配置文件
    详情参见
    http://hsx9566.iteye.com/blog/1142002
      

  2.   

    以下的方法我都试过了,没有解决问题……老天亡我啊!%>_<%
    案例一 【方法】Add External JARs
    【异常】conversion to dalvik format failed with error 1
    【操作】clean一下,项目正常,但是bin里的apk文件和dex文件都没了,运行项目出现错误Can not find **.apk 【方法】User librarys
    【结果】正常。
    案例二 【方法】Add External JARs
    【异常】conversion to dalvik format failed with error 1 【方法】
    ①与src同源的lib,
    ②user library,
    ③将lib设为源文件夹,
    否则编译通过,运行时报错:
    NoClassDefFoundError
    案例三 【方法】this error only appears if I add a specific external Jar to my project
    【异常】conversion to dalvik format failed with error 1
    【操作】I search long time to the right solution but all possible solutions don't work. I even tried to change to android 1.6 instead of 1.5(current version I use)
    案例四 【1】http://hsx9566.iteye.com/blog/11420021)call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %* 2)setup the environment variable (PROGUARD_HOME) manually3)I downloaded Proguard 4.6 and copied the contents of /lib and /bin into /tools/proguard/ which fixed the problem.
    please download latest proguard from the web.4)The only solution i've found to this problem is to change, in proguard.cfg
    -optimizationpasses 5     to     -optimizationpasses 25)downloading the the R11 installer【2】http://code.google.com/p/android/issues/detail?id=18359
    A summary of the issues I faced with Proguard and their solutions (considering SDK r12 on Windows):First, if you have spaces in the path to your Eclipse workspace, you'll get errors of the form "proguard.ParseException: Unknown option". Remove the spaces... seems to be the only way around that. (This means creating a new workspace and migrating things into it.)Second, for this "Error conversion to Dalvik format failed with error 1" thing, DON'T edit proguard.bat! That doesn't seem to help (or it only works for some configurations). Instead, just go to http://sourceforge.net/projects/proguard/files/proguard/4.6/ , get ProGuard 4.6 and extract everything in the proguard4.6 folder to your android-sdk-windows\tools\proguard folder.Once I did these things I was able to do export builds with proguard enabled and stopped getting the various annoying errors.【3】
    http://android.foxykeep.com/dev/fix-the-conversion-to-dalvik-format-failed-with-error-1-with-adt-14
      

  3.   

    你提供的方法我都试过了,还是不行啊!……不过,还是要回馈一下你的热情……%>_<%