我在
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.
只需将此代码添加到您的 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 中的图像压缩器。我认为它对你有用