For the first question;
Please have a look at the option -keeppackagenames in the ProGuard manual. This option will allow you to preserve structure (and names) of the packages you specify in the filter;
e.g. -keeppackagenames com.example.**
For the second question;
This can be achieved as shown below; -keep class com.example.MyClass
Thanks for your quick response. The second answer works great, but the first isn’t quite what I need. -keeppackagenames stops classes in the specified package from being renamed, which I still want them to do. Essentially (in your language) I want to preserve the structure but not the names.
The structure of the packages is modified when the option -repackageclasses or -flattenpackagehierarchy is set in any of the ProGuard configuration files. Please note this can be part of a default configuration file you’re using or consumer rules embedded in a dependency. Removing these options will result in ProGuard not changing the package structures.
The -keeppackagenames option will preserve the names of packages but not classes, I suspect there are some -keep rules that target classes in packages you observe not to be obfuscated.