[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:

 

java.lang.NullPointerException
at proguard.classfile.ProgramClass.constantPoolEntryAccept(ProgramClass.java:537)
at proguard.shrink.UsageMarker.markConstant(UsageMarker.java:1246)
at proguard.shrink.UsageMarker.visitRequiresInfo(UsageMarker.java:1040)
at proguard.classfile.attribute.module.ModuleAttribute.requiresAccept(ModuleAttribute.java:138)
at proguard.shrink.UsageMarker.visitModuleAttribute(UsageMarker.java:739)
at proguard.classfile.attribute.module.ModuleAttribute.accept(ModuleAttribute.java:99)
at proguard.classfile.ProgramClass.attributesAccept(ProgramClass.java:619)
at proguard.shrink.UsageMarker.markProgramClassBody(UsageMarker.java:124)
at proguard.shrink.UsageMarker.visitProgramClass(UsageMarker.java:94)
at proguard.classfile.visitor.MultiClassVisitor.visitProgramClass(MultiClassVisitor.java:67)
at proguard.classfile.visitor.MultiClassVisitor.visitProgramClass(MultiClassVisitor.java:67)
at proguard.classfile.visitor.ClassNameFilter.visitProgramClass(ClassNameFilter.java:128)
at proguard.classfile.ProgramClass.accept(ProgramClass.java:430)
at proguard.classfile.ClassPool.classesAccept(ClassPool.java:124)
at proguard.classfile.visitor.AllClassVisitor.visitClassPool(AllClassVisitor.java:45)
at proguard.classfile.visitor.MultiClassPoolVisitor.visitClassPool(MultiClassPoolVisitor.java:85)
at proguard.classfile.ClassPool.accept(ClassPool.java:110)
at proguard.shrink.Shrinker.execute(Shrinker.java:90)
at proguard.ProGuard.shrink(ProGuard.java:381)
at proguard.ProGuard.execute(ProGuard.java:145)
at proguard.ProGuard.main(ProGuard.java:572)

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)

buildscript {
    ...
    dependencies {
        ...
        classpath 'net.sf.proguard:proguard-gradle:6.2.2'
  }
}
}
force a newer proguard version for your android build