title: Why the proguard script is unable to `keep` the custom-view class I use in layout XML
body: <p>I am sharing my configurations one by one.</p>
  <p>From my Gradle files:</p>
  <pre><code> ext.kotlin_version = '1.3.31'
   dependencies {
          classpath 'com.android.tools.build:gradle:3.4.2'
          classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;
          classpath 'android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  project.ext {
      targetSdkVersion = 25
      compileSdkVersion = 28
      coreMinSdk = 17
      eventbusVersion = '3.1.1'
  }
  // gradle wrapper:
  distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
  </code></pre>
  <p>My proguard script:</p>
  <p>I have tried each and every line of the following statements in my <code>proguard-rules.pro</code> file placed in my <code>/app</code> folder:</p>
  <pre><code>-keep class com.my_package.layout.** { *; }
  -keepnames class com.my_package.layout.MyCustomClass
  -keepclassmembers class com.my_package.layout.MyCustomClass {
     public *;
  }
  -keep class com.my_package.layout.MyCustomClass
  -keep public class com.my_package.layout.MyCustomClass {
      public *;
  }
  </code></pre>
  <p>Please note that <code>com.my_package.layout.MyCustomClass</code> is a valid LinearView extended class.
  I am using it in my layout XMLs.
  When I create a build and run it, there are no errors. This class is working fine.</p>
  <p>Release mode:</p>
  <pre><code>buildTypes {
          release{
              debuggable false
              jniDebuggable false
              minifyEnabled true
              shrinkResources false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      ...
      }
    ...
  }
  </code></pre>
  <p>But in release build, when minifyEnabled is true, the proguard script does not work. It does not keep this file. There is a runtime exception saying that this file cannot be inflated. The app crashes, therefore.</p>
  <p>History:</p>
  <p>Earlier there was no proguard script. At that time android.view.InflateException was reported in the app crash.</p>
  <p>I followed this documentation twice: <a href="https://jebware.com/blog/?p=418" rel="nofollow noreferrer">Understanding -keep directives</a>
  and then I put the script on one by one. This error does not go away unless I modify: <code>minifyEnabled = false</code></p>
  <pre><code>2021-11-16 17:19:40.445 32158-32158/? E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.my_package, PID: 32158 java.lang.RuntimeException: Unable to start activity 
  ComponentInfo{com.my_package/com.my_package.dashboard.ActivityDashboard}:
  android.view.InflateException: Binary XML file line #37 in 
  com.my_package:layout/activity_dashboard: Binary XML file line #37 in 
  com.my_package:layout/activity_dashboard: Error inflating class 
  com.my_package.layout.MyCustomClass
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
          at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
          at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
          at android.os.Handler.dispatchMessage(Handler.java:107)
          at android.os.Looper.loop(Looper.java:214)
          at android.app.ActivityThread.main(ActivityThread.java:7356)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
    ...
  </code></pre>
  <p>Please help.</p>