1.错误 com.android.dex.util.ExceptionWithContext
UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.util.ExceptionWithContext at com.android.dex.util.ExceptionWithContext.withContext(ExceptionWithContext.java:45) at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:369) at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137) at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93) at com.android.dx.command.dexer.Main.processClass(Main.java:729) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at com.android.dx.command.dexer.Main.access$300(Main.java:83) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:170) at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158) at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158) at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158) at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main.processOne(Main.java:632) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106) Caused by: java.lang.NullPointerException at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:87) at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:75) at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:271) ... 22 more ...while processing <init> (Lcom/koabc/launcher/Launcher;)V ...while processing com/koabc/launcher/Launcher$1.class 1 error; aborting Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:developJavabinjava.exe'' finished with non-zero exit value 1
dex 编译BUG,出现情况一般会有以下两个条件,有实例化的内部类,有一个if条件的代码块,并且这个if条件是一个常量(final 修饰,通常值为false)
解决方法:调整代码结构或去掉if代码块或让其值为true