Is proguard.cfg needed for library projects?

前端 未结 3 1752
不知归路
不知归路 2020-11-28 14:23

Assuming I need to apply the same rules for both an application project and a library project on which it relies, do I need to duplicate the content of proguard.cfg from the

相关标签:
3条回答
  • 2020-11-28 14:33
    1. In build.gradle of library project, add line: consumerProguardFiles 'proguard-rules.pro' in buildTypes as:

      buildTypes {
      release {
          minifyEnabled true
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          consumerProguardFiles 'proguard-rules.pro'
      }
      

      }

    2. In build.gradle of root project, enable minifyEnabled. The libraray proguard will work.

    0 讨论(0)
  • Library projects by themselves don't run ProGuard, so they don't use any configuration.

    Application projects obfuscate the entire code base, including any referenced libraries, so they need proper configuration for the application code and for the library code.

    0 讨论(0)
  • 2020-11-28 14:51

    It appears that the answer is "No": Proguard will obfuscate code from the libraries too.

    But that was in 2010 and we know very well that specifications keep changing, especially in the Android development tools. So if a more authoritative answer comes along, I will accept it.

    0 讨论(0)
提交回复
热议问题