jxcore-cordova plugin installation & sample Android mobile app.
Prerequisites:
- phonegap or cordova installed on system already.
- phonegap has external links, hence build requires internet connectivity
- Android SDK and Java (JDK) with PATH updated in bashrc or profile for phonegap/cordova to build and run.
- install android emulator or test app on the device.
Procedure:
$ phonegap create jxctest
[phonegap] executing 'cordova create "/home/arun/workspace/mobileapps/jxctest" "com.phonegap.helloworld" "Hello World" "{\"lib\":{\"www\":{\"id\":\"hello-world-template\",\"version\":\"master\",\"uri\":\"https://github.com/phonegap/phonegap-app-hello-world/archive/master.tar.gz\",\"link\":false}}}"'...
[phonegap] completed 'cordova create "/home/arun/workspace/mobileapps/jxctest" "com.phonegap.helloworld" "Hello World" "{\"lib\":{\"www\":{\"id\":\"hello-world-template\",\"version\":\"master\",\"uri\":\"https://github.com/phonegap/phonegap-app-hello-world/archive/master.tar.gz\",\"link\":false}}}"'
[arun@ jxctest]$ git clone https://github.com/jxcore/jxcore-cordova io.jxcore.node
Cloning into 'io.jxcore.node'...
remote: Counting objects: 2151, done.
remote: Total 2151 (delta 0), reused 0 (delta 0), pack-reused 2151
Receiving objects: 100% (2151/2151), 267.07 MiB | 1.94 MiB/s, done.
Resolving deltas: 100% (1085/1085), done.
Checking connectivity... done.
[arun@ jxctest]$
[arun@ jxctest]$
[arun@ jxctest]$ ls
config.xml hooks io.jxcore.node platforms plugins www
[arun@ jxctest]$
replace the www folder from sample jxctest/io.jxcore.node/sample/www to jxctest/www (so cordova shall use the www folder from jxcore sample for demonstration).
rename the original www to www.orig (in case you need to retain the default contents generated by cordova when app is created OR demo try is on an existing cordova app, so the existing contents of www are retained)
[arun@ jxctest]$ ls -l
total 32
-rw-rw-r-- 1 arun arun 5370 Aug 3 12:31 config.xml
drwxrwxr-x 2 arun arun 4096 Aug 3 12:31 hooks
drwxrwxr-x 8 arun arun 4096 Aug 3 13:38 io.jxcore.node
drwxrwxr-x 2 arun arun 4096 Aug 3 12:31 platforms
drwxrwxr-x 2 arun arun 4096 Aug 3 12:31 plugins
drwxrwxr-x 3 arun arun 4096 Aug 3 14:45 www
drwxrwxr-x 7 arun arun 4096 Aug 3 12:31 www.orig
[arun@ jxctest]$
[arun@ www]$ pwd
/home/arun/workspace/mobileapps/jxctest/io.jxcore.node/sample/www
[arun@ www]$
[arun@ www]$
[arun@ www]$
After replacing www
[arun@ www]$ ls -l
total 8
-rw-rw-r-- 1 arun arun 2543 Aug 3 13:38 index.html
drwxrwxr-x 3 arun arun 4096 Aug 3 13:38 jxcore
[arun@ www]$
[arun@ www]$ ls -l */*
-rw-rw-r-- 1 arun arun 1352 Aug 3 13:38 jxcore/app.js
jxcore/node_modules:
total 4
drwxrwxr-x 2 arun arun 4096 Aug 3 13:38 json-nice
[arun@ www]$
[arun@ jxctest]$ phonegap build android
.....
.....
BUILD SUCCESSFUL
Total time: 6.704 secs
Built the following apk(s):
/home/arun/workspace/mobileapps/jxctest/platforms/android/build/outputs/apk/android-debug.apk
Command finished with error code 0: /home/arun/workspace/mobileapps/jxctest/platforms/android/cordova/build
Note:
www/jxcore/app.js is your entry point to JXcore's JS.
Node modules should go in the www/jxcore/node_modules folder.
Launch app on emulator or device to see the first jxcore - Hello World!! running.
The basic sample provided in the jxcore-cordova results in error. "Uncaught ReferenceError: require is not defined", source: file:///android_asset/www/jxcore.js
To get past this error, in the index.html file, update the timeout value from the default 5 to 500 (may work in lower value as well).
jxcore.isReady(function(){
// register log method from UI to jxcore instance
// so you can call it (app.js) cordova('log').cal(...)
jxcore('log').register(log);
console.log(" ### jxcore.register ## ");
// set the main file and load.
jxcore('app.js').loadMainFile(function (ret, err) {
console.log(" ### did we load app.js ## ");
if(err) {
var msg;
if (!err || err.replace)
msg = err;
else
msg = JSON && JSON.stringify ? JSON.stringify(err) : err;
alert(msg);
} else {
console.log(" ### did we load app.js ## (YES??) ");
jxcore_ready();
}
});
});
}, 500);
--------------error snippet from adb logcat ------------------
I/chromium(32752): [INFO:CONSOLE(3)] "Uncaught ReferenceError: require is not defined", source: file:///android_asset/www/jxcore.js (3)
I/chromium(32752): [INFO:CONSOLE(44)] "Uncaught TypeError: Object function jxcore(x) {
I/chromium(32752): if (!(this instanceof jxcore)) {
I/chromium(32752): return new jxcore(x);
I/chromium(32752): }
I/chromium(32752): this.name = x;
I/chromium(32752): } has no method 'isReady'", source: file:///android_asset/www/index.html (44)
D/dalvikvm(32752): Trying to load lib /data/app-lib/com.jxcore.world-1/libjxcore.so 0x42595a38
D/dalvikvm(32752): Added shared lib /data/app-lib/com.jxcore.world-1/libjxcore.so 0x42595a38
D/jxcore_app_log(32752): JniHelper::setJavaVM(0x416aa258), pthread_self() = 1612675008
D/JX-Cordova(32752): jxcore cordova android initializing
W/jxcore-log(32752): Initializing JXcore engine
W/jxcore-log(32752): JXcore engine is ready
W/jxcore-log(32752): Starting JXcore engine
D/PhoneStatusBar( 1138): disable: 0x00000000 -> 0x00000100 (diff: 0x00000100)
D/PhoneStatusBar( 1138): disable: < expand icons alerts ticker system_info back home recent clock full HIDE* >
W/jxcore-log(32752): Platform android
W/jxcore-log(32752):
W/jxcore-log(32752): Process ARCH arm
W/jxcore-log(32752):
I/jxcore-log(32752): JXcore Cordova bridge is ready!
I/jxcore-log(32752):
W/jxcore-log(32752): JXcore engine is started
I/Timeline( 1057): Timeline: Activity_windows_visible id: ActivityRecord{434966e8 u0 com.jxcore.world/.MainActivity t20} time:5046554
I/ActivityManager( 1057): Killing 32413:com.android.documentsui/u0a26 (adj 15): empty #9
I/XiaomiFirewall( 1984): firewall pkgName:com.jxcore.world, result:0
I/AudioFlinger( 219): setAppName(), name=[system_server], active=[0]
------------post change in timeout value to 500 (from 5) adb logcat. Though the same error occurs, timeout of higher value makes the sample application work fine. -----------------------
D/JsMessageQueue( 5108): Set native->JS mode to OnlineEventsBridgeMode
I/chromium( 5108): [INFO:CONSOLE(3)] "Uncaught ReferenceError: require is not defined", source: file:///android_asset/www/jxcore.js (3)
D/dalvikvm( 5108): Trying to load lib /data/app-lib/com.jxcore.world-1/libjxcore.so 0x428cdc08
D/dalvikvm( 5108): Added shared lib /data/app-lib/com.jxcore.world-1/libjxcore.so 0x428cdc08
D/jxcore_app_log( 5108): JniHelper::setJavaVM(0x41aa7258), pthread_self() = 1612839408
D/JX-Cordova( 5108): jxcore cordova android initializing
W/jxcore-log( 5108): Initializing JXcore engine
W/jxcore-log( 5108): JXcore engine is ready
D/PhoneStatusBar( 1218): disable: 0x00000000 -> 0x00000100 (diff: 0x00000100)
D/PhoneStatusBar( 1218): disable: < expand icons alerts ticker system_info back home recent clock full HIDE* >
W/jxcore-log( 5108): Starting JXcore engine
I/AudioFlinger( 217): setAppName(), name=[system_server], active=[0]
W/jxcore-log( 5108): Platform android
W/jxcore-log( 5108):
W/jxcore-log( 5108): Process ARCH arm
W/jxcore-log( 5108):
I/ThermalEngine( 225): Sensor:batt_temp:32300 mC
I/jxcore-log( 5108): JXcore Cordova bridge is ready!
I/jxcore-log( 5108):
W/jxcore-log( 5108): JXcore engine is started
I/chromium( 5108): [INFO:CONSOLE(73)] " ### Returning an new instance of jxcore ### ", source: file:///android_asset/www/plugins/io.jxcore.node/www/jxcore.js (73)
I/chromium( 5108): [INFO:CONSOLE(128)] " ### register function() called ### ", source: file:///android_asset/www/plugins/io.jxcore.node/www/jxcore.js (128)
I/chromium( 5108): [INFO:CONSOLE(48)] " ### jxcore.register ## ", source: file:///android_asset/www/index.html (48)
I/chromium( 5108): [INFO:CONSOLE(73)] " ### Returning an new instance of jxcore ### ", source: file:///android_asset/www/plugins/io.jxcore.node/www/jxcore.js (73)
I/chromium( 5108): [INFO:CONSOLE(161)] " ### Loading main file called ### ", source: file:///android_asset/www/plugins/io.jxcore.node/www/jxcore.js (161)
I/jxcore-log( 5108): ### app.js reached/loaded ###
I/jxcore-log( 5108):
I/jxcore-log( 5108): {
I/jxcore-log( 5108): "a": 1,
I/jxcore-log( 5108): "b": 2
I/jxcore-log( 5108): }
I/jxcore-log( 5108):
I/jxcore-log( 5108): execPath /data/data/com.jxcore.world/files/www/jxcore
I/jxcore-log( 5108):
I/jxcore-log( 5108): process.cwd /data/data/com.jxcore.world/files/www/jxcore
I/jxcore-log( 5108):
I/jxcore-log( 5108): userPath [ 'com.android.opengl.shaders_cache' ]
I/jxcore-log( 5108):
I/jxcore-log( 5108): Size 720 1280
I/jxcore-log( 5108):
I/jxcore-log( 5108): Screen Brightness 190
I/jxcore-log( 5108):
I/chromium( 5108): [INFO:CONSOLE(51)] " ### did we load app.js ## ", source: file:///android_asset/www/index.html (51)
I/chromium( 5108): [I
Useful links:
https://github.com/jxcore/jxcore-cordova
Note: plugin add via this url shall result in error.
$ phonegap plugin add https://github.com/jxcore/jxcore-cordova.git
Fetching plugin "https://github.com/jxcore/jxcore-cordova.git" via git clone
Repository "https://github.com/jxcore/jxcore-cordova.git" checked out to git ref "master".
shell.js: internal error
Error: EXDEV, cross-device link not permitted '/tmp/git/1438671639709/Changelog.md'
at Error (native)
at Object.fs.renameSync (fs.js:636:18)
at /home/arun/workspace/nodews/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/mv.js:77:8
at Array.forEach (native)
at Object._mv (/home/arun/workspace/nodews/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/mv.js:53:11)
at Object.mv (/home/arun/workspace/nodews/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/common.js:186:23)
at /home/arun/workspace/nodews/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/plugins.js:53:19
at _fulfilled (/home/arun/workspace/nodews/node_modules/phonegap/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/home/arun/workspace/nodews/node_modules/phonegap/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/home/arun/workspace/nodews/node_modules/phonegap/node_modules/cordova/node_modules/q/q.js:749:13)
No comments:
Post a Comment