1. These days I see a training agency talking about how to reduce the size of APK, which mentions confusion. Build. Gradle
android { buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' ... }}}Copy the code
  1. After the confusion, I first found that many third-party libraries could not be used normally, so I searched for three-party confusion rules and added them to Progurad-rules.pro. The default obturation rule is in proguard-android-optimize.txt ({ANDROID_SDK_ROOT}/tools/proguard/).

  2. The running program is abnormal

Method inflate = cls.getDeclaredMethod("inflate", LayoutInflater.class, ViewGroup.class, boolean.class);
Copy the code

The main error is this line. Through Debug and log check, it is found that the inflate method cannot be found, so I went to the Internet to find the confusion about reflection. After querying, I said that the class that calls this method should not be confused, so -keep ***, and the exception is still found. The method getDeclaredMethod is used to look for a breakthrough. If the class cannot be confused, the method inflate of the class cannot be found.

-keep public class * extends androidx.viewbinding.ViewBinding { *; }
Copy the code
  1. And you’re done! So no matter what you find, if you can’t solve it for a while, don’t worry, take your time! Come on! Come on!! Come on!!!!!!!!!!