从 A.S. 生成的最简单的 Hello World 应用程序差不多5MB了!但在 Eclipse 中只有 100KB 左右
当我创建一个项目时,The A.S.默认使用android.support:appcompat-v7
。这是build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "test.elva.testapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
}
在 Eclipse 中,如果将 minSdkVersion 设置为 14,则项目不使用 appcompat-v7 库,并且该类扩展为 Activity
,而不是 AppCompatActivity
最佳答案
您无法比较维度,因为您包含不同的库。
在 Android Studio 中,您将包含 appcompat 库,其中包含代码和资源,以及其他依赖项,例如 support-v4
库。
您可以自定义您的 build.gradle
脚本。
例如,您可以删除 AppCompat
库,并从 dependency
block 中删除该行进行注释
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.android.support:appcompat-v7:23.1.0'
}
AS 使用 AppCompatActivity
作为标准。
是的,它是真实的。原因有很多,主要是 API 21 下 Material Design 的反向移植。
如果没有 appcompat,您就无法使用工具栏之类的 View 或设计支持库提供的 View 。
您可以在这里找到官方信息:
您还可以使用以下方法删除未使用的资源:
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
更多 info here .
关于android - Android Studio 生成的 Apk 文件太大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33182459/