gpt4 book ai didi

android - 是什么让缩小后的 Hello World Android APK 如此之大——800KB?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:56:26 24 4
gpt4 key购买 nike

这不是对当今 Android 应用膨胀的普遍提示*,而是一个非常具体的问题:

如果安装 Android Studio 2.3.3并创建“Hello world”示例应用程序(如 Building your first app official tutorial 中所述),然后构建一个发布 APK,生成的文件为 825KB(我在 Linux 上测试了这个,但我怀疑输出在其他操作系统上是相同的)。

Android Hello world release build

我已经 already enabled ProGuard and there are no images or other resources .

默认情况下,该 APK 中包含什么?

为什么?

如何消除肿胀?

相比之下,in 2013 a Hello World appunder 10Kb .

* 我记得当像样的全功能应用程序只有几百 KB,相比之下像 Uber 这样的 PWA 是 1%相应Android应用的大小

最佳答案

排除所有 AppCompat 库,您将看到大小减少到大约 100kb。

appcompat v7即使您根本不使用它也会自动附加

在您的 build.gradle 中,从“依赖项”中排除:compile 'com.android.support:appcompat-v7:26.+

您还必须编辑 res\values\styles.xml变成这样:

<resources><style name="AppTheme" parent="android:Theme.Light"></style></resources>

(确保删除 <!-- Customize your theme here. --> 行)。此外,在 MainActivity.java , 更改 extends AppCompatActivity一部分给

public class MainActivity extends Activity

关于android - 是什么让缩小后的 Hello World Android APK 如此之大——800KB?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44621410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com