代码之家  ›  专栏  ›  技术社区  ›  Anoop

如何仅为一个模块启用proguard

  •  4
  • Anoop  · 技术社区  · 7 年前

      ` buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }` 
    

    当我继续付款时,此应用程序关闭后。我换衣服的时候还可以 minifyEnabled false .

    以下是我的模块:PayuMoneySdk构建。gradle文件

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

    我可以只启用proguard模块:app吗?它能解决这个问题吗?

    我是编程新手。请帮忙!!

    2 回复  |  直到 7 年前
        1
  •  2
  •   Ashutosh    7 年前

    解决方案是查找需要豁免的方法和类,并将其添加到proguard规则中,如下所示。。

    -keep class com.mm.** {*;}
    -keep class com.company.** {*;}
    -keepclassmembers  class com.mm.** {*;}
    -keepclassmembers  class com.company.** {*;}
    
        2
  •  1
  •   Gurupreet    7 年前
    add below lines in proguard-rule.pro file
    
     -dontwarn okio.**
     # Platform calls Class.forName on types which do not exist on Android to determine platform.
     -dontnote retrofit2.Platform
     # Platform used when running on Java 8 VMs. Will not be used at runtime.
     -dontwarn retrofit2.Platform$Java8
     # Retain generic type information for use by reflection by converters and adapters.
     -keepattributes Signature
     # Retain declared checked exceptions for use by a Proxy instance.
     -keepattributes Exceptions
    
    
    -keep class com.** { *; }