-
Notifications
You must be signed in to change notification settings - Fork 68
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
LoadMainFile JX package #104
Comments
I'm not sure if # index.html
jxcore('app.js').loadMainFile() but inside of app.js you may call: # app.js
require('./app.jx'); Update: I meant app.js from loadMainFile() is different than app.js from inside of your package. Let's then rename the main file to avoid confusion: |
But, if you have .node files and you hope to run it with jxcore-cordova, then see jxcore/jxcore#654 (comment) |
So it seems it does work with Now of course playing with the .node native module does not work as expected, as you pointed out. I guess I will use only memdown for the moment but I'd prefer to find a better solution. If you compiled the .node using ndk-build, wouldn't the .node run well ? Also, when doing the
The .node being in the apk, jxcore should load it instead of extracting it from app.jx. It should show Anyway I hope these discussions will help other newcomers like me. :) |
Good to know :)
On same platform yes, but then the mobile where you deploy is a different machine.
The jx package extraction feature is meant for desktop apps only. It will not work on mobiles. Thus when you create a package for jxcore-cordova usage, you should skip Just keep in www/jxcore the app.jx file and (for testing purpose) .node files in their own folders (starting from node_modules i guess). |
I really don't get how leveldown-mobile can work then... I mean there must be a way to get it working since the project states it's compatible with JXcore. (cc @obastemur) |
That's because leveldown is already embedded in jxcore-cordova plugin. |
Uh. Cool so that means it works indeed. That was not very obvious... :/
Thanks again for your help ! |
This is probably JXcore. How can I reproduce this? |
// app.js
var fs = require('fs');
var express = require('express');
var path = require('path');
var os = require('os');
var PouchDB = require('pouchdb');
var ThaliReplicationManager = require('thali/thalireplicationmanager');
console.log('starting app.js');
var app = express();
app.disable('x-powered-by');
var dbPath = path.join(os.tmpdir(), 'dbPath');
var env = process.env.NODE_ENV || 'production'; // default to production
if (process.env.MOCK_MOBILE) {
global.Mobile = require('thali/mockmobile.js');
}
if (process.platform === 'ios' || process.platform === 'android') {
Mobile.getDocumentsPath(function(err, location) {
if (err) {
console.error("Error", err);
} else {
dbPath = path.join(location, 'dbPath');
console.log("Mobile Documents dbPath location: ", dbPath);
}
});
}
var LevelDownPouchDB = PouchDB.defaults({db: require('leveldown-mobile'), prefix: dbPath});
app.use('/db', require('express-pouchdb')(LevelDownPouchDB, { mode: 'minimumForPouchDB'}));
var db = new LevelDownPouchDB('thali');
app.use(function allowCrossDomain(req, res, next) {
res.header('Access-Control-Allow-Origin', 'http://127.0.0.1:5000');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
});
var server = app.listen(5000, function () {
console.log('Express server started. (port: 5000)');
var manager = new ThaliReplicationManager(db);
manager.start(5000, 'thali');
}); The steps:
At step 2, you could copy to test/www/jxcore and skip step 5 but running cordova run android will be enormously long due to the numbers of folders under node_modules. Step 3 can fail sometimes due to thali installation. If it's the case, simply run Oh and I got the error |
Thanks for this detailed instructions. I was able to reproduce this. It happens for jxcore-cordova 0.0.7 (since Thali installs this exact version). Then I upgraded binaries to 0.0.8 but the app crashed: 11-23 14:39:06.976: W/jxcore-log(2172): Process ARCH ia32
11-23 14:39:06.976: W/jxcore-log(2172): --------- beginning of crash
11-23 14:39:06.977: A/libc(2172): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x3b0029 in tid 2172 (m.example.hello) so I guess this needs to be fixed before we start looking at I'm reopening for now. |
Hello there.
I'm trying to load a (not corrupted ;) cf jxcore/jxcore#651) jx package based on this package.json:
I generate the package with
jx package app.js --show-progress percent
and copy the *.node in the correct folder. (see last paragraph)I load it like this:
And for testing purpose, my app.js only contains
console.log("test");
.Logcat gives log.txt. In short, jxcore throws a "null" error, and "test" is not printed in logcat.
On my computer, running
jx app.jx
does print "test".If it can help I can upload app.jx.
There are several reasons for loading a jx package:
cordova run android
because it merges the folder with the platform www folderAt first I was creating the package with
jx package app.js --extract-what "*.node" --extract-app-root --extract-verbose --show-progress percent
. But doing so, I would get an error in logcat saying that the corresponding directory could not be created (as extraction tried to create a folder inside the apk, so yeah it cannot work).Any ideas ? Thanks for your help.
The text was updated successfully, but these errors were encountered: