我的APK非常大。如何减小它的尺寸?

发布于 2025-02-07 21:10:34 字数 1544 浏览 1 评论 0原文

我的版本APK以20.009 MB(!!)。

刚刚创建了一个非常简单的Android应用程序,将其基于Android Studio Project Project模板之一。我的应用程序只是扫描条形码:-)

这是我的依赖项:

dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'com.google.mlkit:barcode-scanning:17.0.2'

    def camerax_version = "1.1.0-beta01"

    implementation "androidx.camera:camera-camera2:${camerax_version}"
    implementation "androidx.camera:camera-lifecycle:${camerax_version}"
    implementation "androidx.camera:camera-view:${camerax_version}"

    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment:2.4.2'
    implementation 'androidx.navigation:navigation-ui:2.4.2'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

这是我的版本构建参数:

release {
    minifyEnabled true
    shrinkResources true
    proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}

从依赖项可以看出,我添加了ML套件。根据 https://developers.google.com/ml-kit/视觉/条形码扫描/Android ,它不应添加超过3.2 MB。

我运行了大小分析仪,它告诉我:

找不到尺寸的节省建议。

那这里怎么了?为什么我的APK如此庞大?

My release APK comes out at whopping 20.009 MB (!!).

Just created a really simple Android app, basing it on one of the Android Studio project templates. My app just scans a barcode :-)

Here are my dependencies:

dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'com.google.mlkit:barcode-scanning:17.0.2'

    def camerax_version = "1.1.0-beta01"

    implementation "androidx.camera:camera-camera2:${camerax_version}"
    implementation "androidx.camera:camera-lifecycle:${camerax_version}"
    implementation "androidx.camera:camera-view:${camerax_version}"

    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment:2.4.2'
    implementation 'androidx.navigation:navigation-ui:2.4.2'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

Here are my release build parameters:

release {
    minifyEnabled true
    shrinkResources true
    proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}

As is evident from the dependencies, I have added the ML kit. According to https://developers.google.com/ml-kit/vision/barcode-scanning/android, it shouldn't add more than 3.2 MB.

I ran the size-analyzer, and it tells me:

No size saving suggestions found.

So what's going on here? Why is my APK so colossal?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文