android - Apk 大小增加了 drawable-xxxhdpi-v4

标签 android android-studio android-gradle-plugin android-resources

我无法弄清楚这一点。自上次发布以来,我的 apk 大小至少增加了 MB。是的,我 添加了一些新代码和几个矢量 Assets ,仅此而已。但是有这个 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.

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

Gradle 版本 2.14.1 插件版本 2.2.3

应用构建.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'
}

最佳答案

下面的配置对我有用

defaultConfig {
    vectorDrawables.useSupportLibrary = true
  }

关于android - Apk 大小增加了 drawable-xxxhdpi-v4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44984690/

相关文章:

android - 将构建配置值添加到 list 元数据

java - Android - 从SQLite获取数据并显示在ListView中

android - 内存位图转换

java - 我无法从 Edittext 获取数据

android - Android Studio 中的 Smalidea 插件

java - 构建失败并出现异常

android - LocationRequest setInterval (long millis) 和 LocationRequest setFastestInterval (long millis) 的区别

API 18 上未添加 JavaScriptInterface

android - 如何在Android Studio中以编程方式在运行时设置构建变体?

java - 更新 Firebase 性能 SDK 后应用程序未构建