sfinja
sfinja

Reputation: 776

R8 keeps preventing build due to `lombok.NonNull` annotation

When I attempt to Generate Signed App Bundle / APK... of my perfectly building and running app, I get the following error:

Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in missing_rules.txt

The file missing_rules.txt only contains the following:

# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn lombok.NonNull

But when I add exactly what's specified in missing_rules.txt, I keep getting the same error. This error keeps occurring even when I add to my proguard.cfg the following:

-dontwarn lombok.**
-keepattributes *Annotation*

My build.gradle contains the required:

    compileOnly 'org.projectlombok:lombok:1.18.36'
    annotationProcessor 'org.projectlombok:lombok:1.18.36'

So why am I still getting this error?

Note: I ran ..\gradlew dependencies and verified that Lombok appears under compileOnly and annotationProcessor only.

At this point, I am out of ideas. I would appreciate any tip that could help me get past this unexpected hurdle.

My Gradle environment:

------------------------------------------------------------
Gradle 8.9
------------------------------------------------------------

Build time:    2024-07-11 14:37:41 UTC
Revision:      d536ef36a19186ccc596d8817123e5445f30fef8

Kotlin:        1.9.23
Groovy:        3.0.21
Ant:           Apache Ant(TM) version 1.10.13 compiled on January 4 2023
Launcher JVM:  21.0.3 (JetBrains s.r.o. 21.0.3+-12282718-b509.11)
Daemon JVM:    C:\Program Files\Android\Android Studio\jbr (no JDK specified, using current Java home)
OS:            Windows 10 10.0 amd64

Android Gradle Plugin Version: 8.7.3

Upvotes: 2

Views: 154

Answers (1)

sfinja
sfinja

Reputation: 776

Answering my own question, for the benefit of others who may be baffled by this seemingly mysterious problem:

I solved this problem by simply placing

-dontwarn lombok.NonNull

in the proguard.cfg of the app's module, not the library module.

Explanation: My app is made of an app module and a library module. The library module is the one that actually uses Lombok's NonNull annotation, so I thought that the library's proguard.cfgis the one that should contain the -dontwarn lombok.NonNull directive.

I was wrong: It's the other way around.

Upvotes: 1

Related Questions