[CODING/SOLVED] gradle build (android) breaks after upgrading a dependency with NullPointerException thrown at ProgramClass.constantPoolEntryAccept

You’ve just upgraded one of your Android project’s dependencies and when you ./gradlew assembleRelease the build process breaks.

You invoke it again with --stacktrace to find the following exception:

 

[pastacode lang=”java” manual=”java.lang.NullPointerException%0Aat%20proguard.classfile.ProgramClass.constantPoolEntryAccept(ProgramClass.java%3A537)%0Aat%20proguard.shrink.UsageMarker.markConstant(UsageMarker.java%3A1246)%0Aat%20proguard.shrink.UsageMarker.visitRequiresInfo(UsageMarker.java%3A1040)%0Aat%20proguard.classfile.attribute.module.ModuleAttribute.requiresAccept(ModuleAttribute.java%3A138)%0Aat%20proguard.shrink.UsageMarker.visitModuleAttribute(UsageMarker.java%3A739)%0Aat%20proguard.classfile.attribute.module.ModuleAttribute.accept(ModuleAttribute.java%3A99)%0Aat%20proguard.classfile.ProgramClass.attributesAccept(ProgramClass.java%3A619)%0Aat%20proguard.shrink.UsageMarker.markProgramClassBody(UsageMarker.java%3A124)%0Aat%20proguard.shrink.UsageMarker.visitProgramClass(UsageMarker.java%3A94)%0Aat%20proguard.classfile.visitor.MultiClassVisitor.visitProgramClass(MultiClassVisitor.java%3A67)%0Aat%20proguard.classfile.visitor.MultiClassVisitor.visitProgramClass(MultiClassVisitor.java%3A67)%0Aat%20proguard.classfile.visitor.ClassNameFilter.visitProgramClass(ClassNameFilter.java%3A128)%0Aat%20proguard.classfile.ProgramClass.accept(ProgramClass.java%3A430)%0Aat%20proguard.classfile.ClassPool.classesAccept(ClassPool.java%3A124)%0Aat%20proguard.classfile.visitor.AllClassVisitor.visitClassPool(AllClassVisitor.java%3A45)%0Aat%20proguard.classfile.visitor.MultiClassPoolVisitor.visitClassPool(MultiClassPoolVisitor.java%3A85)%0Aat%20proguard.classfile.ClassPool.accept(ClassPool.java%3A110)%0Aat%20proguard.shrink.Shrinker.execute(Shrinker.java%3A90)%0Aat%20proguard.ProGuard.shrink(ProGuard.java%3A381)%0Aat%20proguard.ProGuard.execute(ProGuard.java%3A145)%0Aat%20proguard.ProGuard.main(ProGuard.java%3A572)” message=”” highlight=”” provider=”manual”/]

This is a ProGuard bug, which my friend, has been solved by the ProGuard team ages ago, and your build environment is using an old ProGuard version.

Add this to your build.gradle to force it to use the latest version (as of today it’s 6.2.2, check the latest version here)

[pastacode lang=”java” manual=”buildscript%20%7B%0A%20%20%20%20…%0A%20%20%20%20dependencies%20%7B%0A%20%20%20%20%20%20%20%20…%0A%20%20%20%20%20%20%20%20classpath%20’net.sf.proguard%3Aproguard-gradle%3A6.2.2’%0A%20%20%7D%0A%7D%0A%7D” message=”force a newer proguard version for your android build” highlight=”1,3,5″ provider=”manual”/]

Leave a Reply

Your email address will not be published. Required fields are marked *