gpt4 book ai didi

android - 发行版 APK 与签名 APK 大小之间的巨大差异

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:01:11 34 4
gpt4 key购买 nike

我找到了两种生成发布 APK 的可能方法

  1. 在模块 build.gradle 文件中定义 Product Flavors & Signing Config,然后点击 Run 按钮 (betaRelease Config)

    android {
    signingConfigs {
    my_alias {
    keyAlias 'my_alias'
    keyPassword '*******'
    storeFile file('*******')
    storePassword '******'
    }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 9
    versionName "0.2"
    resConfigs "en","hi","te"
    multiDexEnabled true
    }

    buildTypes {
    release {
    minifyEnabled true
    shrinkResources true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    signingConfig signingConfigs.my_alias
    }
    debug {
    minifyEnabled false
    }
    }

    productFlavors {
    alpha {
    applicationId = "***************"
    resValue 'string', 'app_name', '**********'
    resValue 'string', 'instabug_app_id','*******************'
    manifestPlaceholders = [onesignal_app_id : "*******************",
    onesignal_google_project_number: "************"]
    }
    beta {
    applicationId = "***************"
    resValue 'string', 'app_name', '**********'
    resValue 'string', 'instabug_app_id','*******************'
    manifestPlaceholders = [onesignal_app_id : "*******************",
    onesignal_google_project_number: "************"]
    }
    }
    aaptOptions {
    additionalParameters "--no-version-vectors"
    }
    }
  2. 在 Android Studio 的构建菜单中使用生成签名的 APK 选项

第一个 APK 为 14.5MB,第二个 APK 为 22.5MB,两者之间存在巨大差异。使用 APK 分析器,我可以看到第二个正在复制 res 文件夹中的可绘制对象,如下所示。较小版本的 APK(14.5MB 一个)在所有类型的设备上运行良好。

enter image description here enter image description here

  1. 为什么我需要大一点的?我可以将正常发布的 APK 上传到 Play 商店吗?

  2. 是否有任何配置可以避免重复的可绘制对象?

最佳答案

我将根据我的观察尝试回答这个问题。

1.

Why do I need the bigger one? Can I upload the normal release APK into play store ?

当您通过单击“运行”按钮释放 apk 时,您将针对特定设备(模拟器或 USB 设备),并且您仅为该目标生成资源。这就是为什么您的 .apk 文件较小。

如果您想要部署和定位到所有密度的设备,您应该使用“生成签名 APK”选项为所有设备提供资源(例如图像)。

The smaller release APK (14.5MB one) is working well on all kind of devices.

我认为是因为图像被缩放以适合屏幕。但是您会以这种方式降低图像质量。

2.

Is there any configuration to build avoiding the duplicate drawables?

Providing Resources instruction是这样写的:

The layout direction of your application. ldrtl means "layout-direction-right-to-left". ldltr means "layout-direction-left-to-right" and is the default implicit value.

所有这些意味着您没有重复的可绘制对象,但现在它们位于正确的目录中。

关于android - 发行版 APK 与签名 APK 大小之间的巨大差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41940115/

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