assembleRelease 失败,反应原生 0.50 [英] assembleRelease fails with react-native 0.50

查看:60
本文介绍了assembleRelease 失败,反应原生 0.50的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 gradle-plugin 3.0.0Gradle 发行版 4.1.0反应原生 0.50Linux Fedora 27

Using gradle-plugin 3.0.0 Gradle distribution 4.1.0 react-native 0.50 Linux fedora 27

应用名称是 u1b.项目结构/proj/mob/rn.common(这是 node_modules 和我所有与 js 相关的东西)/proj/mob/a/u1b -- 是安卓应用所在的位置.

app name is u1b. Project structure /proj/mob/rn.common (this is where node_modules is and all my js related stuff) /proj/mob/a/u1b -- is where the android app is.

项目结构与通常由样板 react-native create app 脚本创建的结构不同(因为我的 node_modules 不仅仅是 Android 应用程序的一个级别).但不清楚这是否是一个问题.

the project structure is different than the one normally created by boiler plate react-native create app script (because my node_modules is not just one level up from the android app). But not clear if this is an issue or not.

我一直在调试模式下使用 react-native 库构建我的 android.现在是时候开始构建发布了.但是我遇到了一个问题

I have been building my android with react-native library, in debug mode. Now its time to start building release. But I am running into a problem

bash gradlew assembleRelease 错误:

bash gradlew assembleRelease errors out :

> Task :app:bundleReleaseJsAndAssets
Scanning folders for symlinks in /home/v/devel/mine/proj/mob/rn.common/node_modules (12ms)
Scanning folders for symlinks in /home/v/devel/mine/proj/mob/rn.common/node_modules (9ms)
Loading dependency graph, done.
warning: the transform cache was reset.
bundle: start
bundle: finish
bundle: Writing bundle output to: /home/v/tmp/u1b/app/intermediates/assets/release/index.android.bundle
bundle: Done writing bundle output
bundle: Copying 18 asset files
bundle: Done copying assets

/home/v/tmp/u1b/app/intermediates/res/merged/release/drawable-mdpi/src_jsapp_img_material_ic_local_library_black_48dp_android_drawablexxhlack_48dp.png: **error: Invalid filename.  Unable to add.**

它正在查看的图像文件确实不存在.但是,我不知道该文件名是如何构造的,以及为什么要查找它.

The image file it is looking at is, indeed not there. However I have no idea how that file name is constructed and, why it something is looking for it.

由于错误,我的 gradle.properties 包含一个用于切换到旧 apk 的标志

my gradle.properties contains a flag to switch to old apk due to a bug

# https://github.com/react-community/react-navigation/issues/1976
android.enableAapt2=false

有人可以阐明图像名称的确定方式以及可能导致错误的原因

could somebody shed a light on how the image names are decided and what might be causing the error

谢谢

推荐答案

已解决.

我弄清楚了有问题的文件名是如何构造的,然后我能够减轻似乎图像文件路径太深"的问题.

I figured out how the offending file name was constructed, and then I was able to mitigate what seemed to be 'too deep of a path for image file'.

基本上就是下面的文件名

Basically the file name below

src_jsapp_img_material_ic_local_library_black_48dp_android_drawablexxhblack_48dp.png

src_jsapp_img_material_ic_local_library_black_48dp_android_drawablexxhblack_48dp.png

是文件驻留在我的 javascript 文件夹中的路径的串联(从 node_modules 所在的同一级别开始)

was concatenation of a path where the file resided in my javascript folder (starting from same level where node_modules are )

我的 index.android.js 引用了一个静态图标文件

my index.android.js referes to a static icon file

icon: require('./src/js.app/img/material/ic_local_library_black_48dp/android/drawable-xxhdpi/ic_local_library_black_48dp.png'),

当打包器构造那个有问题的文件名时,它基本上是将路径的元素附加到文件中,并进行了一些修改".就像去掉一个点(所以js.app变成了jsapp)

When the bundler constructed that offending file name, It was basically appending elements of the path to the file together, with some 'mangling'. Like removing a dot (so js.app became jsapp)

我只是将该文件复制到更高级别的目录(以减少发布构建的文件名的长度)然后发布版本开始工作.

I just copied that file over to a higher level directory (to reduce the length of the release-constructed file name) And then the release build started working.

违规文件名的长度约为 177 个字符.不知道为什么它会为发布版本带来问题.我怀疑这是 android 工具的限制,而不是 facebook 的问题.我在 buildTools 25.0.3 和 26.0.2 之间来回切换(这也意味着切换 android 插件版本......整个过程花费了相当多的时间).但问题出在任一 buildtools 版本中.

The length of the offending file name was about 177 characters long. Not sure why it created problem for the release build. I suspect this is a limitation of android tools, not facebook's problem. I switched back and forth between buildTools 25.0.3 and 26.0.2 (that also meant switching android plugin versions .. .and that whole thing took quite a bit of time). But the problem was in either of the buildtools versions.

所以我只是认为 js 静态资源(例如图像)的深层目录结构现在是一个问题.所以最好使用较小的目录深度.

So I just figured deep directory structures for js static resource (eg images) is a problem for now. So better use smaller directory depths.

这篇关于assembleRelease 失败,反应原生 0.50的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆