Android Proguard does not inline

后端 未结 2 1704
轻奢々
轻奢々 2020-12-11 16:26

I am using the latest Android SDK (4.1) and I tried exporting a signed jar with Proguard enabled. However, after decompiling the optimized APK, I noticed that methods that I

相关标签:
2条回答
  • 2020-12-11 16:37

    In your module's build.gradle file, you should look at:

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-project.txt')
            signingConfig signingConfigs.release
        }
    }
    

    and replace proguard-android.txt with proguard-android-optimize.txt, which doesn't include the -dontoptimize line while keeping the dalvik problems away (see Eric Lafortune's answer).

    0 讨论(0)
  • 2020-12-11 16:46

    This recent Android SDK disables all optimizations by default, see ${sdk.dir}/tools/proguard/proguard-android.txt:

    -dontoptimize
    

    The alternative optimizing configuration only disables a few optimizations, see ${sdk.dir}/tools/proguard/proguard-android-optimize.txt:

    -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
    

    You can specify your preferred configuration file in project.properties.

    You can verify which complete configuration ProGuard is using by adding the option -printconfiguration.

    Some optimizations have been disabled in order to avoid bugs in older versions of the Dalvik VM (!code/simplification/arithmetic,!code/simplification/cast), and some optimizations may have been disabled to avoid bugs in older versions of ProGuard (!field/*,!class/merging/*).

    Note that -whyareyoukeeping refers to the shrinking step, which removes unnecessary classes/fields/methods as a whole. Methods that are not removed may be inlined in the optimization step (unless explicitly specified otherwise with -keep).

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