Apk大小增加drawable-xxxhdpi-v4

时间:2017-07-08 09:35:25

标签: android android-studio android-gradle android-resources

我无法弄清楚这一点。自上次发布以来,我的apk大小增加了至少另一个MB。是的,我已经添加了一些新的代码和几个矢量资产。但是有这个drawable-xxxhdpi-v4被添加到我的apk中,我的png图像在那里重复。 看一看。

Summary

As you can see, old apk has 0 bytes for this folder and the new apk has my png assets copied there.

有人遇到过这个吗? 我似乎无法弄清楚为什么这是hapenning。它甚至不像这些是新的图像。这个文件夹中0字节的旧字符现在占用空间。

Gradle版本2.14.1 插件版本2.2.3

App build.gradle:

defaultConfig {
    applicationId project.APPLICATION_ID
    minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK_VERSION)
    targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION)

    versionCode Integer.parseInt(project.VERSION_CODE)
    versionName project.VERSION_NAME

    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true


    resConfigs "en", "fr"

    javaCompileOptions {
        annotationProcessorOptions {
            includeCompileClasspath true
        }
    }
}

lintOptions {
    abortOnError false
    disable 'MissingTranslation'
}

dataBinding {
    enabled = true
}
dexOptions {
    preDexLibraries = false
}

// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
    noCompress "db"

}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

buildTypes {
    def BOOLEAN = "boolean"
    def TRUE = "true"
    def FALSE = "false"
    def LOGGING = "LOGGING"
    def STRICT_MODE = "STRICT_MODE"
    def DEBUG_MODE = "DEBUG_MODE"

    release {
        minifyEnabled true
        proguardFiles 'proguard-rules.txt', 'proguard-here-sdk.txt'
        // Resource shrinking confis
        shrinkResources true // remove unused resources
        signingConfig signingConfigs.release
        debuggable false
        buildConfigField BOOLEAN, LOGGING, FALSE
        buildConfigField BOOLEAN, STRICT_MODE, FALSE
        buildConfigField BOOLEAN, DEBUG_MODE, FALSE
        zipAlignEnabled true

        applicationVariants.all { variant ->
            if (variant.buildType.name == 'release') {
                variant.mergeAssets.doLast {
                    delete(fileTree(dir: variant.mergeAssets.outputDir, includes: ['ic_launcher_debug*']))
                }
            }
        }
    }
lintOptions {
    disable 'InvalidPackage'
}

packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
}

2 个答案:

答案 0 :(得分:0)

以下配置对我有用

defaultConfig {
    vectorDrawables.useSupportLibrary = true
  }

答案 1 :(得分:-1)

是。当您使用Coccoon.io编译您的应用程序的Android版本时,它会发生相同的情况。应用程序的大小增加了一倍。这不仅仅是因为这样的文件夹,而是Coccoon为cordova提供的应用程序库。

我不知道这对你有帮助,但至少是一个线索。