【发布时间】:2016-10-03 07:41:05
【问题描述】:
我正在开发包含以下依赖项的应用程序
模块级
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.google.android.gms:play-services:9.0.0' **// for GCM**
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.squareup.picasso:picasso:2.5.2' **//Rounding and displaying image from URL**
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.github.lecho:hellocharts-library:1.5.8@aar' **// For bar graph**
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile 'com.google.firebase:firebase-core:9.0.0' **// Analytics**
}
项目级别
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.realm:realm-gradle-plugin:1.0.1' // Database
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
我的
/Assets /150kb 使用字体真棒文件。
/java - 644 KB
/res - 740 KB(使用高分辨率图像 1920*1280 大小 220kb 用 tinypng 压缩)
已应用 ProGuard。 删除未使用的文件和代码。
问题
我的应用程序大小仍然是 7.03MB
如何减小应用程序大小?我不知道为什么这是 7.03MB
是否有任何计算可以给出apk中依赖项使用的大小?
就像 google play 服务在 apk 中占用了大约 200kb。
【问题讨论】:
-
您已经编译了所有 Google Play 服务,而不仅仅是 GCM
-
为不同的处理器架构(如 Armb、x86 等)创建不同的构建,而不是通用 apk 文件。并关注以下文章medium.com/pregbuddy-engineering/…
-
请参阅此处developers.google.com/android/guides/setup 或改用 FCM,因为您已经拥有 Firebase 核心
-
@cricket_007 我们不需要为 FCM 添加其他依赖项,因为根据文档。 “您还应该为要使用的 Firebase SDK 添加依赖项。我们建议从提供 Firebase Analytics 功能的 com.google.firebase:firebase-core 开始。请参阅下面的可用库列表。” firebase.google.com/docs/android/setup