gpt4 book ai didi

android - 如何在 android studio 中减小 Apk (.apk) 的大小

转载 作者:行者123 更新时间:2023-12-04 23:45:43 26 4
gpt4 key购买 nike

当我运行我的应用程序大小的 apk 将为 21 MB。即使我启用了proguard。我使用 android studio 来运行项目。在项目文件中,src 文件夹大小为 8.62 MB,lib 文件夹大小为 400 KB。那么我如何减小 .apk 文件的大小。
实际上 .apk 文件在某些​​日子之前是 8 mb 并且具有相同的图像,但在 paypal 集成之后,我的应用程序大小将增加到 21 mb。
构建文件夹的大小为 127 MB。

build.gradle(module app) 是:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.oi.food"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

packagingOptions{
exclude 'AndroidManifest.xml'
} }

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile files('libs/httpmime-4.1.1.jar')
compile files('libs/apache-mime4j-0.6.jar')
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.paypal.sdk:paypal-android-sdk:2.14.1' }

最佳答案

我通过在模块 app build.gradle 文件中添加此代码来解决此问题。

 android {
packagingOptions{
exclude 'AndroidManifest.xml'
exclude 'lib/arm64-v8a/libcardioDecider.so'
exclude 'lib/arm64-v8a/libcardioRecognizer.so'
exclude 'lib/arm64-v8a/libcardioRecognizer_tegra2.so'
exclude 'lib/arm64-v8a/libopencv_core.so'
exclude 'lib/arm64-v8a/libopencv_imgproc.so'
exclude 'lib/armeabi/libcardioDecider.so'
exclude 'lib/armeabi-v7a/libcardioDecider.so'
exclude 'lib/armeabi-v7a/libcardioRecognizer.so'
exclude 'lib/armeabi-v7a/libcardioRecognizer_tegra2.so'
exclude 'lib/armeabi-v7a/libopencv_core.so'
exclude 'lib/armeabi-v7a/libopencv_imgproc.so'
exclude 'lib/mips/libcardioDecider.so'
exclude 'lib/x86/libcardioDecider.so'
exclude 'lib/x86/libcardioRecognizer.so'
exclude 'lib/x86/libcardioRecognizer_tegra2.so'
exclude 'lib/x86/libopencv_core.so'
exclude 'lib/x86/libopencv_imgproc.so'
exclude 'lib/x86_64/libcardioDecider.so'
exclude 'lib/x86_64/libcardioRecognizer.so'
exclude 'lib/x86_64/libcardioRecognizer_tegra2.so'
exclude 'lib/x86_64/libopencv_core.so'
exclude 'lib/x86_64/libopencv_imgproc.so'
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.paypal.sdk:paypal-android-sdk:2.14.1'
}

关于android - 如何在 android studio 中减小 Apk (.apk) 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36540015/

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