对于Gradle 3.2.1,是否需要Proguard?

时间:2019-07-07 11:56:14

标签: android proguard facebook-android-sdk

我第一次这样做。使用适用于Android应用程序的Facebook SDK。 我正在关注本教程。 https://developers.facebook.com/docs/sharing/android/

我的应用是gradle 3.2.1 我需要在这里使用ProGuard吗? 我应该在此链接的给定两个代码之间写什么代码: https://developer.android.com/studio/build/shrink-code.html?fbclid=IwAR3hmG6hOtzfyiHa3Sehxa4o2j9vq9sPrk8ZVbr-WWyUDakiskFMZQgloJM

android {

buildTypes {

    release {

        // Enables code shrinking, obfuscation, and optimization for only
        // your project's release build type.

        minifyEnabled true

        // Enables resource shrinking, which is performed by the
        // Android Gradle plugin.

        shrinkResources true

        // Includes the default ProGuard rules files that are packaged with
        // the Android Gradle plugin. To learn more, go to the section about
        // R8 configuration files.

        proguardFiles getDefaultProguardFile(
                'proguard-android-optimize.txt'),
                'proguard-rules.pro'
    }

}

...

}

还有另一个代码:

android {     ...

buildTypes {

    release {

        minifyEnabled true

        proguardFiles getDefaultProguardFile(
          'proguard-android-optimize.txt'),

          // List additional ProGuard rules for the given build type here. By default,
          // Android Studio creates and includes an empty rules file for you (located
          // at the root directory of each module).
          'proguard-rules.pro'

    }
}
flavorDimensions "version"

productFlavors {

    flavor1 {

      ...
    }
    flavor2 {

        proguardFile 'flavor2-rules.pro'
    }
}

}

它下面还有一些小代码,我应该添加哪一个? 请解释。

1 个答案:

答案 0 :(得分:0)

添加ProGuard文件时,您必须添加

        useProguard true

在gradle文件(模块)中