assembleRelease fails with react-native 0.50

♀尐吖头ヾ 提交于 2020-01-07 05:39:21

问题


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

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.

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.

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 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.

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

thank you


回答1:


Resolved.

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

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

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'),

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.

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.

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



来源:https://stackoverflow.com/questions/47465804/assemblerelease-fails-with-react-native-0-50

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!