Adds some keep rules for R8 use cases

ajesh/r8-usecases
Ajesh R 1 month ago
parent cb83bc0ee7
commit c170a8ffb1

@ -1,19 +1,34 @@
# In your library's consumer-proguard-rules.pro
-keep, allowoptimization class * implements com.example.mylibrary.MyWorker {
-keep, allowoptimization class ** implements com.example.mylibrary.MyWorker {
<init>();
<methods>;
}
-whyareyoukeeping class com.example.mylibrary.MyWorker{
<methods>;
}
-keepattributes *Annotation*
-keep @interface com.example.mylibrary.OnEvent
-keepclasseswithmembers class * {
-keepclasseswithmembers class **{
<init>();
@com.example.mylibrary.OnEvent <methods>;
}
-keep class com.example.mylibrary.EventBus {
<methods>;
}
-whyareyoukeeping class com.example.mylibrary.EventBus {
<methods>;
}
-keep @interface com.example.mylibrary.ReflectiveExecutor
-keep @com.example.mylibrary.ReflectiveExecutor class *{
-keep @com.example.mylibrary.ReflectiveExecutor class **{
# Keep the public, no-argument constructor so that an instance of the class can be created.
# <init> is the internal name for a constructor.
public <init>();

@ -19,3 +19,11 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class com.example.mylibrary.WorkerLoader {
<methods>;
}
-whyareyoukeeping class com.example.mylibrary.WorkerLoader {
<methods>;
}

@ -95,14 +95,14 @@ class MainActivity : ComponentActivity() {
WorkerLoader.loadAndRun(workerClassName)
val eventBus = EventBus()
val listener = CustomListener()
eventBus.dispatch(listener)
// val listener = CustomListener()
// eventBus.dispatch(listener)
//
// val runner = TaskRunner()
// val task1 = ImportantBackgroundTask()
val runner = TaskRunner()
val task1 = ImportantBackgroundTask()
runner.process(task1) // This will be executed.
// runner.process(task1) // This will be executed.
@ -219,7 +219,7 @@ data class ThemeSettings(
class CrashTestWorker : MyWorker {
override fun doWork() {
// This log will never appear in a release build because the class won't be found
Log.d("CrashTestWorker", "Important work is being done!")
Log.e("CrashTestWorker", "Important work is being done!")
}
}
@ -234,6 +234,6 @@ class CustomListener {
@ReflectiveExecutor
class ImportantBackgroundTask {
fun execute() {
Log.e("ImportantBackgroundTask", "Executing the important background task... ✅")
Log.e("ImportantBackgroundTask", "Executing the important background task... ✅")
}
}

Loading…
Cancel
Save