Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Problems building apk with Ant Release

I have no problems building my app in eclipse but once I try to do it via ant, it does not build. I've used "android update project -p ." to generate the build build.xml and proguard.cfg file. I tried "ant compile" and it builds fine as well. The app includes a android library and has external libs if it matters. Anyone here's the error that prints out when I try to do a "ant release",

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.util.ExceptionWithContext
    at com.android.dx.util.ExceptionWithContext.withContext(ExceptionWithContext.java:46)
    at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:340)
    at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131)
    at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85)
    at com.android.dx.command.dexer.Main.processClass(Main.java:369)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
    at com.android.dx.command.dexer.Main.access$400(Main.java:59)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:134)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
    at com.android.dx.command.dexer.Main.processOne(Main.java:313)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
    at com.android.dx.command.dexer.Main.run(Main.java:185)
    at com.android.dx.command.dexer.Main.main(Main.java:166)
    at com.android.dx.command.Main.main(Main.java:90)
Caused by: java.lang.NullPointerException
    at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:84)
    at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:243)
    ... 23 more

I'm pretty much perplexed at the moment so hopefully someone can shed some light.

like image 542
Dave Avatar asked Aug 26 '11 05:08

Dave


1 Answers

I think my answer on this page also applies on this error. This happens when you initialize an anonymous class in dead code.

An explanation why it would only happen in release and not in debug is that the dead code is removed when optimized.

like image 82
Albert-Jan Verhees Avatar answered Oct 16 '22 09:10

Albert-Jan Verhees