Android Studio新项目文件大小太大 [英] Android Studio new project file size too big
问题描述
我刚刚在Android Studio 2.2.3中创建了一个新的android项目,仅带有一个空的Activity,但它仍然在设备上使用4.11 MB,考虑到它确实包含一个空的Activity,我认为这是很多的.为什么要占用这么多空间?有可能减小其尺寸吗?我下载的应用程序具有更多功能,并且具有更多图片,颜色等,并且小于2MB.
I just created a new android project in Android Studio 2.2.3 with just an empty Activity and still it uses 4.11 MB on the device which I think is a lot given that it does contain a single empty Activity. Why is it taking so much space? Is it possible to reduce its size? I have downloaded applications with more functionality and which have more pictures, colors, etc. and are less than 2MB.
下面是我创建项目所使用的步骤.
Bellow are the steps I used to create the project.
然后,在Sony Xperia上运行该应用程序后,我会获得此信息.
Then, after running the application on a Sony Xperia I get this information.
分析内存时,我得到了.
And when profiling the memory I get.
已分配了3MB和1MB的免费空间.
Which has allocated 3MB and ust 1MB free.
这是build.gradle文件:
This is the build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.survey.research.surveycollect"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
testCompile 'junit:junit:4.12'
}
推荐答案
调试apk或发布apk?如果调试apk,则总是比发行版稍大.在释放模式下,执行minifyEnabled = true
,shrinkResources = true
,zipAlignEnabled = true
.它将使发布文件的大小缩小到调试文件的30%(基于我的经验).
Debug apk or release apk? If debug apk its always slightly bigger than release. In release mode, do minifyEnabled = true
, shrinkResources = true
, zipAlignEnabled = true
. It will shrunk your release file size to around 30% (base on my exp) of your debug files.
这篇关于Android Studio新项目文件大小太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!