Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Release Build Fails #144

Open
blissland opened this issue Apr 11, 2016 · 5 comments
Open

Android Release Build Fails #144

blissland opened this issue Apr 11, 2016 · 5 comments

Comments

@blissland
Copy link

When building a signed release version of my app it fails when attempting to load the main file:

jxcore('app.js').loadMainFile()

The error message reported is:

No such native module /data/data/my.app.name/files/www/jxcore/app.js

The debug version of the app works fine.

I found what I believe is the same issue reported in the Thali Project:

thaliproject/Thali_CordovaPlugin#594

I am using version 0.1.1 of the plugin.

UPDATE
After more investigation here are a few more clues:
1/ The signed release app does sometimes start without errors. So maybe looking at a timing/threading issue.
2/ When the app fails the fs extension functions defined in jxcore_cordova.js (existssync, readfilesync) are not even invoked to try to read the app.js. So maybe the problem is somewhere in the main jxcore code rather than the cordova part?
3/ The message "no such native module" seems to be for core node.js modules. There seems to be no attempt made to load app.js

@blissland
Copy link
Author

Anybody know how to set NODE_DEBUG environment variable for android app so I can investigate this issue further?

@vjrantal
Copy link
Contributor

Wanted to let you know that we identified that this issue occurs only with devices running Android 5.0.x (API level 21), but not on 5.1.x (API level 22). However, we were not able to identify the root cause nor find a workaround to make it work on all devices.

@Vaporexpress
Copy link

I have a device (Alcatel Pixi 3 4.5) that fails on Android 5.1 but on other devices Nexus 4 (5.1.1), Asus TF101 (4.4.4) and Vexia Zippers XL (4.2.2) work OK with the following compilation procedure:
$ git clone https://github.com/jxcore/jxcore.git
$ cd jxcore
For v8 engine:
$ ./configure
$ make clean && make
$ build_scripts/android-configure.sh /usr/local/android-ndk-linux
$ build_scripts/android_compile_v8.sh /usr/local/android-ndk-linux
$ cd ..
$ git clone https://github.com/jxcore/jxcore-cordova.git
$ mkdir jxcore-cordova/src/android/jxcore-binaries
$ rm -f jxcore-cordova/src/android/jxcore-binaries/*
$ cp -f jxcore/out_android/android/bin/* jxcore-cordova/src/android/jxcore-binaries/
$ cd jxcore-cordova/src/android/jni
Here modify "Android.mk" file to remove "libmozjs" and add "libv8_base" and "libv8_nosnapshot" modules and then build shared library with:
$ /usr/local/android-ndk-linux/ndk-build

NOTE: After trying many different builds the problem focuses on some devices and V8 engine compilation with Release Builds (Android debug builds works), If I compile with SM engine everything is OK.

@blissland
Copy link
Author

OK so I think I found a fix for this issue ;-)

Ths fix is in the main jxcore source, in the file /src/node.js. See my commit here:

blissland/jxcore@b9697e2

The problem was that in the release builds the function process.cwd() was returning an empty string and in the debug builds the function was returning '/system/bin/'. If process.cwd() is empty the path.resolve call does not return an absolute path for the module which means it is interpreted as a native module which results in the error occurring.

I was not able to figure out why process.cwd() fails in the release builds and not in the debug builds. The above fix makes my app work fine now but there may be a better general solution.

@Vaporexpress
Copy link

@blissland With your fix now works on my device with this issue.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants