Home Features Docs Blog Support GitHub

NoClassDefFoundError when setting ProguardLevel to 'all'

I just set proguardLevel ‘all’ to decrese my app size. When building I get the following error:

dex2oat F 771 8789 /Users/rolandvigh/public-repo/aosp/art/compiler/oat_writer.cc:655] java.lang.NoClassDefFoundError: org.apache.commons.logging.impl.ServletContextCleaner

I read other threads about this problem and checked my proguard cfg file. But there is this included:
-keep class org.apache.commons.logging.impl.** { *; }

I also created an proguard.append.cfg file and added this line to it:
-keep class org.apache.commons.logging.impl.ServletContextCleaner { *; }

which gets included in the generated proguard file at build time.

But I still get the same error. Does anyone had similar problems? Any ideas what is going wrong there?

I found a solution.

I added implementation 'javax.servlet:javax.servlet-api:3.1.0' to my dependencies and added this to my proguard.append.cfg:

-keep interface javax.servlet.ServletContextListener {*;}
-keep class javax.servlet.ServletContextEvent {*;}
1 Like