For some reason, one of our data class model is being obfuscated or removed during build and we had to add @Keep
annotation to it to work.
@Keep
data class CommonNotification(
val title: String,
val description: String,
val channel: String,
val action: String = DEFAULT_VALUE_STRING,
val actionData: String? = DEFAULT_VALUE_STRING,
val bigImage: String? = DEFAULT_VALUE_STRING,
val environment: String = BuildConfig.BUILD_TYPE
)
But running ./gradlew lint
is failing with this error
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in
/Users/user/Desktop/Projects/Mobile/Android/App/app/libs/AndroidCommon/build/outputs/mapping/debug/missing_rules.txt.
ERROR: R8: Missing class java.lang.invoke.StringConcatFactory (referenced from: java.lang.String com.project.android.common.data.remote.responses.notifications.CommonNotification.toString())
Any idea what is the problem and solution?
I tried a solution from this issue tracker
Adding -dontwarn java.lang.invoke.StringConcatFactory
but the getting Unresolved class name
warning/error in the rules file. I am using JAVA VERSION_17
and AGP 8.1.1
The issue was fixed after adding this rule:
-dontwarn java.lang.invoke.StringConcatFactory
You may get a red error/warning as Unresolved class name
as it cannot locate the package but that is what dontwarn
actually do, to exclude a class that is not existing in a project build from lint checking.
References: