0

I want to know if its possible to keep the name of a public static inner Class but renaming the parent classname.

My code looks like this:

public class MyDao extends AbstractDao {

    public static final String TABLENAME = "BOX_DOWNLOAD";

    public static class Properties {
        public final static Property ID = new Property(0, Long.class, "ID", true, "ID");
        public final static Property Name = new Property(1, String.class, "name", false, "NAME");
        public final static Property Done = new Property(2, Boolean.class, "done", false, "DONE");
        // SOME MORE CONSTANTS
    };

    // SOME CODE WHICH CAN BE OBFUSCATED

}

I want ProGuard to replace: MyDao (the className)

the PROPERTIES' variables (ID, Name, Done)

I want ProGuard NOT to replace:

TABLENAME (variable name)
PROPERTIES (className only) 

I tried this

-keepclassmembers class * extends de.greenrobot.dao.AbstractDao {
  public static <fields>;
  public static class *;
}

But this is not working. The classNames are not obfuscated.

// EDIT I forgot to say that there are several classes like MyDao. Eg. MyDao1, MyDao2, etc.

I want to use wildcards.

4

2 に答える 2

2

Cfr。ProGuardマニュアル>使用法>保持オプション

-keepclassmembers class de.greenrobot.dao.MyDao {
    String TABLENAME;
}

-keep class de.greenrobot.dao.MyDao$Properties

更新:「MyDao $ Properties」という名前を保持する場合、ProGuardの現在のバージョンは「MyDao」という名前も保持しているように見えます(InnerClasses属性が保持されていない場合でも)。これは、厳密に必要なものよりもいくらか保守的です。

于 2013-01-29T20:57:42.013 に答える
0

I have made following scripts, which works for me.

-keep class my.dao.package.*$Properties {
    public static <fields>;
}

-keepclassmembers class my.dao.package.** {
    public java.lang.String TABLENAME;    
}

I have used wildcard for inner classes, which worked.

于 2015-02-05T10:53:48.943 に答える