为什么我的 Flutter Android apk 中的图像只有 1x1 像素?

问题描述 投票:0回答:1

我在

android/app/src/main/res/drawable/notification.png
中有一个 110x110 的图像作为我的通知图标。当我在我的设备上
flutter run
这个时,它显示正确。但是,如果我
flutter build apk
并安装生成的 .apk,我的通知是一个方形白框。我解压了 .apk,
android/app/src/main/res/drawable/notification.png
处的图像现在是 1x1.

android flutter apk
1个回答
0
投票

只需将此代码添加到您的 build.gradle,

aaptOptions { cruncherEnabled = false }

像这样,

android {
    compileSdkVersion 30

    defaultConfig {
        applicationId "com.demo.myapp"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    aaptOptions { cruncherEnabled = false }
}

因为这个文件在构建过程中禁用了 Android Asset Packaging Tool 中的图像压缩器。我认为它对你有用

© www.soinside.com 2019 - 2024. All rights reserved.