【发布时间】:2016-03-23 10:47:48
【问题描述】:
我的项目中有多个库,例如
dependencies {
compile files('libs/universalloaderlibrary.jar')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.jakewharton:butterknife:7.0.1'
//noinspection GradleCompatible
compile 'com.google.android.gms:play-services-gcm:7.3.0'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.loopj.android:android-async-http:1.4.8'
compile 'com.android.support:multidex:1.0.1'
}
和其他库。 他们是否过多地增加了应用程序的大小。我的项目中有超过 25 个库。现在 APK 大小为 11 MB,我必须在其中添加更多功能。 可能是什么原因?
我对此有一些疑问。
什么会占用更多内存?
- 在项目中添加了模块。
- 文件添加为 JAR 文件。
- 我们添加的 Gradle 依赖项就像
compile 'com.android.support:appcompat-v7:22.2.1'。
我通过启用 Proguard 了解到,设置 minifyEnabled true 可以减小应用程序大小。
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
它们在图片背后是如何工作的?
我们应该避免在项目中使用多个库吗?
我想到了很多关于减小 APK 大小的问题。 任何形式的建议和帮助都将是可观的。 提前致谢。
【问题讨论】:
标签: android android-gradle-plugin apk android-library android-proguard