How to Keep/Exclude a Particular Package Path When Using Proguard

How to keep/exclude a particular package path when using proguard?

You don't specify in what way it doesn't work. Your configuration keeps the names of all public classes in the specified package:

-keep public class com.myapp.customcomponents.*

The following configuration keeps the names of all public classes in the specified package and its subpackages:

-keep public class com.myapp.customcomponents.**

The following configuration keeps the names of all public/protected classes/fields/methods in the specified package and its subpackages:

-keep public class com.myapp.customcomponents.** {
public protected *;
}

exclude packages from proguard

You can use ProGuard-style regular expressions for the class name:

-keep class !com.myapp.data.**,com.myapp.** { *; }

Proguard: How to keep everything except specific condition?

To keep everything except classes in your own package you can use the rule that you already pointed out (excluding the brackets):

-keep class !my.package.name.** { *; }

This will implicitly keep everything else.
You still can add additionally -keep rules for your classes if needed.

The rule for the -dontwarn should work in a similar way:

-dontwarn !my.package.name.**,**

You can also add similar -dontnote rules if needed.

How to exclude package name and sub package name while using progaurd In Android Studio?

On Android Studio 4.0 and above double asterisks ()** won't compile anymore. So if you want to fix this error and exclude sub-packages do it like this

-keep class in.myapplication.app.samplePackage.*.* {*;}

this will exclude the packages inside samplePackage as well



Related Topics



Leave a reply



Submit