Closed ghost closed 9 years ago
I think I misspoke about device plugin working. We install cordova core plugins in the create script, but will only enable them when you push vanilla cordova apps.
We do, of course, want to fix this. I'll see if I can find some workaround for you where you can manually just enable cordova plugins in your own build of CADT.
Hello guys,
@mmocny and the rest of the team: Do you know maybe something new concerning adding plugins while building own CADT? For instance, I really need the device plugin. I think that this plugin will be essential in a lot of cases.
In advance, thank you for any help. Have a nice day! :)
Tommy, we are working on adding a solution to cca
for this, but I think I've found a workaround for you which you can use today.
cca push
sends only the chrome application assets (i.e. the root www/
) folder, and so if you extend your app to add any cordova plugins they aren't actually going to be used.
However, you can use another tool called harness-push
to push the prepared platform assets, together with all the cordova additions (i.e. platforms/android/assets/www/
), which includes the set of plugins your app needs.
You can find harness-push inside the chrome-app-developer-tool repo.
Setup instructions:
> git clone CADT # you already did this
> cd CADT/harness-push
> npm install
> cd node_modules/chrome-app-developer-tool-client/ # this nested node_module should be moved out eventually, but for now this step is required
> npm install
Push Instructions:
> cd YOUR_APP
> cca prepare && CADT/harness-push/harness-push.js push .
Note: Whenever you switch between cca push
and harness-push
you should delete the app loaded in CADT.
Looking forward to hearing if this works for you! Thanks!
@mmocny thank you for your response.
I tried what you posted and actually, device.js
file is added, however, it looks like cordova
doesn't see it.
For instance, I added device
plugin:
cca plugin add org.apache.cordova.device
and then invoked:
cca prepare && CADT/harness-push/harness-push.js push .
Now, I can see that device.js
file is loaded and even device
object is available, but all properties from this object are null:
Device { available: false, platform: null, version: null, uuid: null, cordova: null… }
And additionally, if I tried to add another plugin from cordova, like bluetoothserial
:
cca plugin add com.megster.cordova.bluetoothserial
Then, bluetoothSerial.js
file is not loaded and bluetoothSerial
object is not available.
Do you have any ideas why it is not working? Thank you in advance, if you have any workarounds for me :)
You will also need to build a version of CADT with those plugins installed. Adding those plugins to a project only registers that you wish to use them. (This is because the native bits of the plugins cannot be pushed).
Unfortunately, installing plugins didn't resolve the problem.
Before building own CADT, I checked if plugins are actually installed using:
cordova plugin list
I got:
android.support.v4 1.0.0 "Android Support v4"
com.google.playservices 19.0.0 "Google Play Services for Android"
com.megster.cordova.bluetoothserial 0.3.0 "Bluetooth Serial"
org.apache.appharness.AppHarnessUI 0.0.1 "AppHarnessUI"
org.apache.cordova.UrlRemap 1.0.0 "URL Remapper"
org.apache.cordova.battery-status 0.2.10 "Battery"
org.apache.cordova.camera 0.3.1 "Camera"
org.apache.cordova.contacts 0.2.12 "Contacts"
org.apache.cordova.device 0.2.11 "Device"
....
and so on... We can see that bluetoothserial
plugin and device
plugin are installed. So, I installed my build of CADT into my device using:
cordova run --device
Then, I added these plugins into my project:
cca plugin add com.megster.cordova.bluetoothserial
cca plugin add org.apache.cordova.device
And when I run my project, device
and bluetoothSerial
objects are available, however all properties from device
object are still null
and invoking bluetoothSerial
methods causes following error:
Do you have the same problems? Or is it working for you?
I did not try bluetoothSerial, but I did use device successfully with the steps I outlined -- the same steps I believe you are following.
From CADT:
> cordova plugin ls
android.support.v4 1.0.0 "Android Support v4"
com.google.playservices 19.0.0 "Google Play Services for Android"
org.apache.appharness.AppHarnessUI 0.0.1 "AppHarnessUI"
org.apache.cordova.UrlRemap 1.0.0 "URL Remapper"
org.apache.cordova.battery-status 0.2.10 "Battery"
org.apache.cordova.camera 0.3.1 "Camera"
org.apache.cordova.contacts 0.2.12 "Contacts"
org.apache.cordova.device 0.2.11 "Device"
...
From my app:
> cca plugin ls
cca v0.3.2-dev
org.apache.cordova.device 0.2.11 "Device"
org.apache.cordova.engine.crosswalk 0.0.1-dev "Crosswalk Engine"
org.apache.cordova.file 1.3.0 "File"
org.apache.cordova.inappbrowser 0.5.1 "InAppBrowser"
org.apache.cordova.labs.keyboard 0.1.2 "Keyboard"
org.apache.cordova.network-information 0.2.11 "Network Information"
org.apache.cordova.statusbar 0.1.7 "StatusBar"
org.chromium.bootstrap 1.0.2 "Chrome Apps Core"
org.chromium.common 1.0.2 "Chrome Apps Common Utils"
org.chromium.i18n 1.0.1 "Chrome Apps I18n API"
org.chromium.navigation 1.0.1 "Chrome Apps Navigation"
org.chromium.polyfill.blob_constructor 1.0.0 "XHR blob returnType shim"
org.chromium.polyfill.customevent 1.0.2 "CustomEvent constuctor shim"
org.chromium.polyfill.xhr_features 1.0.1 "XHR Blob Response Type Polyfill"
org.chromium.runtime 1.0.2 "Chrome App Runtime"
org.chromium.storage 1.0.1 "Chrome Apps Storage API"
Running:
> chrome-harness-push push . # chrome-harness-push is just what harness-push.js is named when npm link-ed globally
From Chrome DevTools console connected to app running inside CADT:
> device
Device {available: true, platform: "Android", version: "L", uuid: "...", cordova: "3.6.0-dev-70cdca3"…}
@tommyJS - Can you also check for errors / stack traces in "adb logcat". Often the NPObject message indicates a problem on the Java side.
I noticed that in my project deviceready
event from cordova is not fired. I have no idea why.
However, I assume that it's something wrong with my project, because when created an empty project, then device
and bluetoothSerial
plugins work correctly!
@mmocny: Thank you very much for this workaround! I owe you beer :)
And meanwhile, I will investigate what's wrong with my project and what prevents deviceready
event.
@agrieve: Thank you for this suggestion, it might be useful for the investigation. Greetings! :)
Prosze Bardzo!
A na piwo sie chetnie spotkamy.. Bedziez czasem na PhoneGap Day EU w Berlinie?
Wow, fajnie byłoby się tam spotkać! :) Sprawdzę, czy nie mam czegoś na 26 września i dam Ci znać na priv.
Problems disappeared when I deleted attaching cordova.js in my app:
<script src="cordova.js"></script>
Oh, you were adding cordova.js
manually in your window?
Thats probably something other users with cordova experience will do, woops. Cca does the step for you, but I don't think we explicitly mention that.
Should we update cordova-js to warn & no-op if window.cordova is already defined?
(Also: PhoneGap Day Berlin has been postponed indefinitely. A few of us Googlers already have tickets so we may do a small event at the Google office in Berlin instead, so stay tuned. But it looks like I will not be there.)
It would be fine for beginners to know that it is forbidden and any messages informing about adding it explicitly would be useful.
(Yep, I've already noticed it. If you have any information, please let me know. Cheers!)
Filed: MobileChromeApps/mobile-chrome-apps#317
Unable to support third plugins! Please mention it clearly on docs. I'm using "io.gvox.phonecalltrap.PhoneCallTrap", taking hours to find why the plugin was not loaded until bring me here.
@Imskull Thanks, just pushed a docs update for this. Sorry!
In this issue: https://github.com/MobileChromeApps/chrome-app-developer-tool/issues/31
@mmocny wrote:
I've already build own CADT from Source (https://github.com/MobileChromeApps/chrome-app-developer-tool#building-from-source-ios-or-android) and org.apache.cordova.device is still not available.
However, according to: https://github.com/MobileChromeApps/chrome-app-developer-tool/blob/master/createproject.sh#L162-L183
It should be available.
Any ideas? Thanks in advance.