How to configure ProGuard to keep names of inner class members?
I am pretty sure something like this should do the trick:
-keepclassmembernames class com.myapppackage.MyOuterClass$** { *; }
So please double check.
Testing showed that { *; } part is necessary. Although I cannot explain why.
Could someone with insight please elaborate.
How to keep Fields and Methods of Inner Class in Proguard (Not only the Class itself)
From the bytecode point of view, inner classes are ordinary classes; they only have ...$...
names (and InnerClasses attributes, for the sake of reflection and compilers). ProGuard doesn't treat them differently. Your additional rules would therefore only match inner classes that have the annotation. The best solution I see at this time is to specify the main rule and then annotate the inner classes as well.
Background: the patterns in ProGuard's rules specify the elements that are matched and the elements that are kept as a result (with slight variations between -keep
, -keepclassmembers
, and -keepclasseswithmembers
). You therefore can't specify "IF some class is matched THEN keep some other class". This is very rarely needed and rules can already be complex, but I am considering a more general extension.
Keep from R8 obfuscating: inner classes or interfaces, where outer class extends or implements
You should be able to use the following conditional keep rule:
-if class com.example.** implements io.foo.bar.MyInterface
-keep class com.example.<1>$*
If a class in package com.example
implements io.foo.bar.MyInterface
keep all its inner classes.
Proper Proguard configuration to keep static inner class
All of those should work (only Object -> java.lang.Object). You can check bin/proguard/seeds.txt to see if they are listed. Otherwise, you might be modifying the wrong configuration file, or there might be a typo in the names.
Related Topics
How to Start a New Android Activity Using Class Name in a String
Google Sign in Signed APK Not Working
Is Dalvik's Memory Model the Same as Java'S
How to Draw an Arrowhead (In Android)
Getlocationonscreen() VS Getlocationinwindow()
How to Make Burst Mode Available to Camera
Android:Save a Bitmap to Bmp File Format
Language Detection with Data in Postgresql
Java Equivalent to JavaScript's Encodeuricomponent That Produces Identical Output
How to Include the Spongy Castle Jar in Android
Serializing and De-Serializing Android.Graphics.Bitmap in Java
How to Change the Edittext Text Without Triggering the Text Watcher
Eclipse: Jvm Terminated. Exit Code=2