Android Studio does not shrink my app

人盡茶涼 提交于 2020-01-04 02:54:05

问题


I am trying to reduce my apk size (because google play services increased size of my app from 65kb to 5MB) using shrink as told in this web: http://tools.android.com/tech-docs/new-build-system/resource-shrinking

i added minifyEnabled true and shrinkResources true

The problem is that as told in that web this should be displayed in gradle log:

:android:shrinkDebugResources
Removed unused resources: Binary resource data reduced from 2570KB to 1711KB: Removed 33%

But nothing is displayed in gradle log.... only this:

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild
:app:compileDebugNdk UP-TO-DATE
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareComAndroidSupportSupportV42100Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds6587Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase6587Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug
:app:dexDebug
:app:processDebugJavaRes UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug

BUILD SUCCESSFUL

Total time: 37.258 sec

this is my code:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 14
        targetSdkVersion 19
    }

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

    dependencies {
        compile 'com.google.android.gms:play-services-ads:6.5.87'
    }
}

来源:https://stackoverflow.com/questions/27861557/android-studio-does-not-shrink-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!