【发布时间】:2018-10-17 18:22:02
【问题描述】:
我正在尝试生成我的第一个 .apk 并在过去几天遇到错误。
我在堆栈溢出和 github 上搜索 ans,但没有任何帮助。
通过指令 here我能够构建调试版本,但是当运行 gradlew assembleRelease 时出现错误
E:\p1\placementScript\android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigationstack_dist_views_assets_backicon.png: 错误:未编译的 PNG 文件作为参数传递。必须先编译 进入 .flat 文件.. 错误:解析覆盖失败。
FAILURE:构建失败并出现异常。
- 出了什么问题:任务 ':app:processReleaseResources' 执行失败。 无法处理资源,请参阅上面的 aapt 输出了解详情。
package.json
{
....
"dependencies": {
"babel-preset-es2015": "^6.24.1",
"react": "^16.4.1",
"react-native": "^0.55.4",
"react-native-fcm": "^16.2.3",
"react-native-firebase": "^5.0.0",
"react-native-push-notification": "^3.1.1",
"react-native-view-shot": "^2.4.0",
"react-navigation": "^2.12.1"
}
....
}
和android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "26.0.3"
minSdkVersion = 16
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
和android/app/build.gradle
...
defaultConfig {
...
}
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
}
}
}
splits {
...
您希望我上传的任何其他文件请询问。
PS:- 我的 src 文件夹中有很多 .png 文件(所有 .js/etc 文件都在其中),我是否需要指定一些它们是我的资产的位置
【问题讨论】:
标签: react-native gradle build.gradle