简体   繁体   English

Google Play 控制台 apk 太大

[英]Google Play Console apk too big

I've just finished building my android app, but when I try to upload it to the Google Play Console it says the apk is too large.我刚刚完成了 android 应用程序的构建,但是当我尝试将其上传到 Google Play 控制台时,它说 apk 太大。 When looking it up it says you can add extension files, however I'm not sure how to now separate my app so I can upload an initial smaller size and then add the extension.查找时它说您可以添加扩展文件,但是我不确定现在如何分离我的应用程序,以便我可以上传初始较小的大小,然后添加扩展名。 Do I essentially need to create two apps, one which is the smaller base file and the other with all the extra features?我是否需要创建两个应用程序,一个是较小的基本文件,另一个是具有所有额外功能的应用程序?

Step 1:步骤1:

Replace all of Images,Icons with vector drawable or将所有图像、图标替换为矢量可绘制或

remove unnecessary Images from Drwable Folder从 Drwable 文件夹中删除不必要的图像

Step 2:第2步:

remove unnecessary variable and library that are not used in code删除代码中未使用的不必要的变量和库

Step 3: Add in Build.App第 3 步:添加 Build.App

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

} }

Step 4: Kindly Make Bundle for Play Console not Apk file第 4 步:请为 Play 控制台而不是 Apk 文件制作捆绑包

I have a few suggestions for you which can help solve your issue:我有一些建议可以帮助您解决问题:

  1. Use the Android App Bundle使用 Android 应用程序包

    • Google States:谷歌状态:

      In the second half of 2021, new apps will be required to publish with the Android App Bundle on Google Play. 2021 年下半年,新应用程序将需要在 Google Play 上使用 Android App Bundle 发布。 New apps larger than 150 MB must use either Play Feature Delivery or Play Asset Delivery.大于 150 MB 的新应用必须使用 Play Feature Delivery 或 Play Asset Delivery。

      Therefore, you should use AAB files as they are the currently recommended publishing format, and soon the required one.因此,您应该使用 AAB 文件,因为它们是当前推荐的发布格式,很快就会成为必需的。

    • Android App Bundle also brings reduced download sizes for your users: Android App Bundle 还为您的用户减少了下载大小:

      Google Play uses your app bundle to generate and serve optimized APKs for each device configuration, so only the code and resources that are needed for a specific device are downloaded to run your app. Google Play 使用您的 app bundle 为每个设备配置生成和提供优化的 APK,因此只下载特定设备所需的代码和资源来运行您的应用程序。 You no longer have to build, sign, and manage multiple APKs to optimize support for different devices, and users get smaller, more-optimized downloads.您不再需要构建、签名和管理多个 APK 来优化对不同设备的支持,并且用户可以获得更小、更优化的下载。

    • More information: https://developer.android.com/guide/app-bundle更多信息: https://developer.android.com/guide/app-bundle

  2. Use the APK/App Bundle Analyser使用 APK/App Bundle Analyzer

    • In Android Studio, go to Build > Analyse APK and select an APK or App Bundle file.在 Android Studio、go 中构建 > 分析 APK 和 select APK 或 App Bundle 文件。 Here you can find what files in your APK/App Bundle require the most storage space, and therefore you can reduce them to fit under the upload limit in the Google Play Console.在这里,您可以找到 APK/App Bundle 中的哪些文件需要最多的存储空间,因此您可以减少它们以适应 Google Play 控制台的上传限制。

    • More info: https://developer.android.com/studio/build/apk-analyzer更多信息: https://developer.android.com/studio/build/apk-analyzer

  3. Shrink, obfuscate, and optimize your app:缩小、混淆和优化您的应用程序:

    • In your app level build.gradle file add the following:在您的应用级别 build.gradle 文件中添加以下内容:
android {
    buildTypes {
        release {
            // Enables code shrinking, obfuscation, and optimization
            minifyEnabled true

            // Enables resource shrinking, which is performed by the Android Gradle plugin.
            shrinkResources true

            // Removes unused code, and carries out other code optimisations
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'
        }
    }
    ...
}
  1. If none of the above solve the problem, then you will have to use Play Feature Delivery: https://developer.android.com/guide/app-bundle/play-feature-delivery如果以上方法都不能解决问题,那么您将不得不使用 Play Feature Delivery: https://developer.android.com/guide/app-bundle/play-feature-delivery

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM