Upgraded to Android Studio 1.0 & Gradle 1.0.0, aap

2019-05-19 10:23发布

I performed an upgrade to Android Studio 1.0 & Gradle 1.0.0 today, from Android Studio 0.86 & Gradle 0.13. Prior to the upgrade, I was using "runProguard = true" option in my release builds extensively, to reduce my APK size to just under 50 MB, to meet Google Play Store's APK size restrictions.

However, with the new Android Studio 1.0 / Gradle 1.0.0 with "minifyEnabled = true", I am seeing resulting APKs at 55.6 MB, which is significantly larger than before. The debug build APKs are resulting in 55.6 MB as well, leaving me to conclude that the minifyEnabled option isn't actually working.

I've updated my Gradle configuration to work with the new Gradle version and is listed below:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.1'

defaultConfig {
    minSdkVersion 9
    targetSdkVersion 21
}

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

dependencies {
   compile 'com.android.support:appcompat-v7:21.+'
   compile 'it.sephiroth.android.library.picasso:picasso:2.3.4.3'
}

As far as I can see, everything seems to be okay with the build.gradle file, but minifyEnabled just doesn't seem to work. What's strange is that there are no compilation errors reported when I generate the release build. Does anyone have any ideas on how to get minifyEnabled to work?


EDIT (12/10/2014):

Alright, it appears that this issue is not related to minifyEnabled at all, but to an older bug with aapt that was previously resolved with Gradle 0.9.1, where aapt would increase the size of PNG files if they were already pre-optimized.

http://tools.android.com/tech-docs/new-build-system

The bug has resurfaced with Gradle 1.0.0. This bug can be reproduced by doing the following:

  1. Optimize PNG files with TinyPNG or other PNG optimization tools.
  2. Use Android Studio 1.0 with Gradle 1.0.0.
  3. Compile Android project with or without aaptOptions newPNG flag.
  4. Open APK file and compare PNG files against original PNG files for size.

The issue has been reported on the AOSP tracker and they seem to be aware of it: https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=tinyPNG&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=65335

FYI, this post should probably be merged with this previous StackOverflow post, as it is exactly this same old problem: Export signed app without "optimizing" png images

0条回答
登录 后发表回答