HI Elliot ,
Thank you, you are correct I had an issue with folder location.
Now It seems that I can compile a basic project but I have an issue now
when I am trying to use any plugin.
So to recap I have cordova 3.3 installed and using crosswalk 5 stable. I
am trying to use the accelerator plugin as per the example here:
https://crosswalk-project.org/#documentation/cordova/add_plugins
so this are the steps to create the project:
$ cordova create hello com.hello.com hello
then I converted added the android platform and converted to crosswalk:
$ cd hello
$ export ANDROID_HOME=/home/davide/android-sdk-linux
$ export CURRENT_DIR="$PWD"
$ export CORDOVA_ANDROID_DIR="${CURRENT_DIR}/platforms/android"
$ rm platforms/android -rf
$ cordova platforms add android
$ cd $CORDOVA_ANDROID_DIR
$ rm CordovaLib/* -r
$ cp ~/Downloads/crosswalk-cordova-5.34.104.5-arm/framework/* CordovaLib/ -a
$ cp ~/Downloads/crosswalk-cordova-5.34.104.5-arm/VERSION .
$ android update project --subprojects --path . --target "android-19"
$ cd CordovaLib
$ echo "** building xwalk Cordova lib"
$ ant debug > $CURRENT_DIR/antdebug_1.txt
$ cd ..
$ echo "** building xwalk ANDROID "
$ ant debug > $CURRENT_DIR/antdebug_2.txt
At this point the sample project has been converted to crosswalk. I am
testing on a Nexus S phone with android 4.1.2
So I would like to add a plugin [Accelerator] to this converted sample
project.
$ cd $CURRENT_DIR
$ plugman install --platform android --project /platforms/android/
--plugin
https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git#r0.2.4
Then I modify the index.html
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
<!-- display x,y,z accelerometer coordinates -->
<p style="color: white;">x: <span id="x">0</span></p>
<p style="color: white;">y: <span id="y">0</span></p>
<p style="color: white;">z: <span id="z">0</span></p>
</div>
and the index.js
onDeviceReady: function () {
app.receivedEvent('deviceready');
// listen to accelerometer events every 100ms
console.log(("TEST PLUGIN: " + (typeof navigator.accelerometer ===
'undefined' ? "NOT PRESENT" : 'CORRECTLY LOADED')));
navigator.accelerometer.watchAcceleration(
// success handler
function (evt) {
document.getElementById('x').innerHTML = evt.x;
document.getElementById('y').innerHTML = evt.y;
document.getElementById('z').innerHTML = evt.z;
},
// error handler
function (e) {
alert("accel fail (" + e.name + ": " + e.message + ")");
},
// options: update every 100ms
{ frequency: 100 }
);
},
Note that I added a console.log to check if the plugin is loaded. The
other files are all the same as when the project has been created
[including also the config.xml in the root folder]
When I try to launch the project
$ cordova run --device
and in another shell window trace the adb log messages:
$ adb logcat chromium:D *:S | logcat-colorize
I have in the log:
I [ 8385] chromium [INFO:CONSOLE(42)] "TEST PLUGIN: NOT PRESENT",
source: file:///android_asset/www/js/index.js (42)
I [ 8385] chromium [INFO:CONSOLE(43)] "Uncaught TypeError: Cannot
read property 'watchAcceleration' of undefined", source:
file:///android_asset/www/js/index.js (43)
So it seems that the plugin is not loaded.
I noted that when a plugin is added using "Cordova plugin add..." it
create and json file in the /plugins/ folder. This JSON is then read
when "cordova build" is executed and create some additional entries in
/platforms/android/res/xml/config.xml.
There should be in my opinion something like :
<feature name="Accelerometer">
<param name="android-package"
value="org.apache.cordova.devicemotion.AccelListener" />
</feature>
Is there anything that I am missing ? Do I have to modify anything else
to have the plugin usable ?
_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help