1

I have my project package name as

in.myapplication.app

and I have a package which contains several packages as well like this

in.myapplication.app.samplePackage

in.myapplication.app.samplePackage.SubPackage

Now I want to exclude all the classes present inside samplePackage package including subpackage classes also. I tried this keep rule inside progaurd file

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

But it only allows the classes that are in samplePackage and not in samplePackage.SubPackage

I have checked similar questions

  1. How to keep/exclude a particular package path when using proguard?
  2. Make Proguard completely ignore package

Nothing working and tried to use these

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

But it's showing me a warning

Unresolved reference name in shrinker config file

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

AgentP
  • 6,261
  • 2
  • 31
  • 52
  • This works for me -keep class in.myapplication.app.samplePackage.** { *; } – Style-7 Jul 11 '20 at 18:12
  • @Style-7 which android version are you using? I am using android studio 4.0 I presume that it exists on 4.0 and above – AgentP Jul 12 '20 at 05:37

2 Answers2

0

The correct rule for keeping everything in package in.myapplication.app.samplePackage and all subpackages is:

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

The warning you see could be a false negative, see issue 153616200.

sgjesse
  • 3,793
  • 14
  • 17
  • See Daniel's comment on this answer https://stackoverflow.com/a/4904402/9365212 I am experiencing same thing – AgentP Aug 05 '20 at 11:52
0

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

AgentP
  • 6,261
  • 2
  • 31
  • 52
  • The issue in Android Studio 4.0 is in the IDE which wrongly flags the `**` syntax. It still works with the actual R8 compilation, so I suggest to keep using it, as the semantics is not the same as e.g. `*.*`. See [issue 153616200](https://b.corp.google.com/issues/153616200). – sgjesse Aug 06 '20 at 07:39
  • @sgjesse So it's the IDE problem then? – AgentP Aug 06 '20 at 08:51
  • Yes the IDE will make a class like `com.example.**` with "Unresolved class name", but the R8 compiler will process it just fine. Please follow the referenced bug for progress on fixing this. – sgjesse Aug 06 '20 at 11:36