【问题标题】:AAB Bundle Size too large in React Native AndroidReact Native Android 中的 AAB Bundle Size 太大
【发布时间】:2021-04-04 16:22:15
【问题描述】:

我有一个非常简单的 react native 应用程序,它不使用任何大量资源,只有 2 张图片(总共 146kb)。使用此https://reactnative.dev/docs/signed-apk-android 生成 .aab 文件后,.aab 文件的大小为 27 Mb。一旦我在 playstore 上发布版本并在我的设备上进行测试,应用程序的大小没有变化,它仍然是 27 Mb。我尝试了以下方法来减小应用程序的大小,但无济于事。

How to reduce Android APK size in react-native?

How to decrease React-Native android App Size

https://medium.com/@aswinmohanme/how-i-reduced-the-size-of-my-react-native-app-by-86-27be72bba640

以下代码是我目前在 build.gradle 文件中使用的代码。我不确定我哪里出错了,或者为什么 .aab 文件的大小是 27 Mb,即使在我的设备上安装之后(我知道 .aab 文件与多个 apk 配置捆绑在一起,大小应该会减小安装时在 7-10 Mb 之间)。

任何帮助将不胜感激提前感谢!

def enableSeparateBuildPerCPUArchitecture = true
def enableProguardInReleaseBuilds = true

splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            debuggable false
            shrinkResources true
            zipAlignEnabled true
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }

【问题讨论】:

    标签: android react-native build.gradle apk


    【解决方案1】:

    它仅在您将其上传到应用商店后才有效,因此本地安装的 .aab 文件通常比直接从 Play 商店下载的文件更重。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-29
      • 1970-01-01
      • 1970-01-01
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多