android - 未编译的 PNG 文件作为参数传递。必须先编译成 .flat 文件
问题描述
当我将 React Navigation 添加到 Project 并同步它但出现错误时
android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigation_src_views_assets_backicon.png:
error: uncompiled PNG file passed as argument.
Must be compiled first into .flat file.. error: failed parsing overlays.
我搜索并得出结论
您也可能会遇到作为参数传递的未编译的 PNG 文件。必须先编译成 .flat 文件。错误:解析覆盖失败。现在有一个解决方法。
将 android.enableAapt2=false 添加到 android/gradle.properties。
但有一个错误
WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..
我还是错了
文件 app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = true
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.ir.babahassan.shop"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.1.0"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-maps')
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-location:11.6.0' // disable if you don't want to use enableHighAccuracy: true in geolocation
implementation 'com.google.android.gms:play-services-base:11.6.0'
implementation 'com.google.android.gms:play-services-maps:11.6.0'
implementation project(':react-native-android-open-settings')
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
文件 settings.gradle
rootProject.name = 'ir.babahassan.shop'
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':react-native-android-open-settings'
project(':react-native-android-open-settings').projectDir = new File(settingsDir, '../node_modules/react-native-android-open-settings/android')
include ':app'
文件 gradle.properties
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#android.useDeprecatedNdk=true
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=*********
MYAPP_RELEASE_STORE_PASSWORD=*********
MYAPP_RELEASE_KEY_PASSWORD=*********
android.enableAapt2=false
解决方案
对于任何卡住的人。请勿android.enableAapt2=false
用于android/gradle.properties
临时固定。签出这个答案
推荐阅读
- java - 当使用 `openjdk:11` 或 `openjdk:8` 和 CGroups 的实验标志时,仍然需要 `-Xmx`
- c# - C# 使用按钮在 DateTimePicker 显示上一个和下一个日期
- wpf - WPF更改带有透明背景的isSelected上的TabItem图像背景
- c# - 如何通过 MakeGenericType 制作通用 lambda
- c# - Unity 3D Raycast 没有朝着正确的方向发展
- sql - 如何在 SQL 中选择两个表之间不匹配的行?
- bixby - 将 Bixby http 请求直接发送到 localhost
- eclipse - 使用 Eclipse (MacOS) 将经过验证的提交签名到 GitHub (GPG)
- mysql - 根据产品是否在用户的购物车中,在每个产品中显示适当的按钮
- google-sheets - 如果 Google 表格每天匹配 A1 标准,如何在单元格 B1 中添加计数(计数 + 1)?