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
Android Textwatcher.Aftertextchanged VS Textwatcher.Ontextchanged
Remove Listview Items in Android
Android Studio Error "Installed Build Tools Revision 31.0.0 Is Corrupted"
Why Doesn't Logcat Show Anything in My Android
How to Check If an Activity Is the Last One in the Activity Stack for an Application
Android App Specific Soft Keyboard
How to Create Standard Borderless Buttons (Like in the Design Guideline Mentioned)
What Should I Use Android Accountmanager For
How to Change Package Name of Android Project in Eclipse
Highlight Text in Textview or Webview
Android 5.0 Android:Elevation Works for View, But Not Button
Android - Open Resource from @Drawable String
Creating Temporary Files in Android
How to Convert Dp, Px, Sp Among Each Other, Especially Dp and Sp
How to Start Android Service on Installation
How to Show a Dialog to Confirm That the User Wishes to Exit an Android Activity