android - 使用 Play 服务 gcm 时如何减小 apk 大小

标签 android gradle google-cloud-messaging apk

我生成的签名 apk 大小为 30kB,当我将 play services gcm 添加到 gradle 文件时,apk 大小增加到 800kB。通过缩小资源,apk 大小变为 600kB。

如何进一步减小应用程序大小?

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.test.mytest"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            shrinkResources true
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])      
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
}

最佳答案

来自 http://proguard.sourceforge.net/manual/examples.html#application

-optimizationpasses 3

-overloadaggressively

-repackageclasses ''

-allowaccessmodification

这些可能会有所帮助。 (特别是3遍)

关于android - 使用 Play 服务 gcm 时如何减小 apk 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34529504/

相关文章:

Android Activity 从左到右在前面

android - 关于 productFlavors with gradle

gradle - Gradle:如何使规则创建的ZipTask成为Maven发布工件

iOS GCM 错误代码 501

php - 在 GCM 的 Android 设备上不接收消息

java - 将数字转换为 double

android - 让 Android 像 Android Spinner 一样对待 HTML Select?

android - 如何在 Android 中设置按钮内可绘制矢量的大小?

java - 使用 Grade/ant 进行 Cordova 5 构建会抛出 java 编译错误

Android 推送通知 - 如何获取设备 ID