MobileChromeApps / chrome-app-developer-tool

Mirror of Apache Cordova app harness
Other
202 stars 33 forks source link

cca push disables non-manifest-linked cordova plugins #31

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi all,

I added cordova plugin using: cca plugin add org.apache.cordova.device

and then invoked: cca push --watch --target=my_ip

Unfortunately, device variable is not defined.

However, when I invoke: cca run

Then, the app is installed on my phone and I can get access to the device variable. Do you know why this plugin is not attached when invoking cca push? I am sure that it is possible somehow to attach this plugin, because other plugins are attached by default. Unfortunately, I do not know how to do that.

Can you help me?

mmocny commented 9 years ago

A general note about cca run vs cca push: when you push an app, you are only sending over web assets (aka, your chrome app / www contents). All the native platform files & plugin code has been pre-built into the Chrome App Dev Tool (CADT).

So generally speaking, you cannot install a 3rdparty plugin and have it work with the CADT that we publish. You could, however, build your own CADT with the plugin added.

Now, that said, org.apache.cordova.device should work, because we do pre-bundle the cordova core plugins, as you can see here. Somethings up!

Quick Question: when you did cca push, did you do that from inside a directory containing a chrome app, or from inside a cordova workspace (the result of cca create, would have platforms/, plugins/, www/ etc)?

agrieve commented 9 years ago

The device plugin isn't installed for CCA apps by default, you'd need to manually install it via "cca install org.apache.cordova.device". So, I assume that's what @tommyJS has done?

When you cca push, we don't actually look at what cordova plugins you have installed, and instead just derive them from the manifest.json. So... I think to fix this, we'd need to track what extra Cordova plugins are installed and send that to the CADT e.g. maybe a "cordova_plugins": {"org.apache.cordova.Device": "0.1.0"} within manifest.mobile.json, or something along these lines.

mmocny commented 9 years ago

Another low-road option is to add a menu to CADT main screen to manually enable plugins?

mmocny commented 9 years ago

Actually I think we are overcomplicating. CADT by default should only support chrome app environment. If you want optional plugins, you're in cordova development land now and should be pushing assets "the cordova way" which I believe includes the plugins/PLATFORM.json file as part of the push, right?

Either we add a flag to cca push to just default to this way when you're inside a cordova workspace?

ghost commented 9 years ago

@mmocny: I make cca push from inside a cordova workspace created by cca create @agrieve : Yep, I used exactly cca plugin add org.apache.cordova.device to install device plugin in my project

@mmocny wrote:

Now, that said, org.apache.cordova.device should work, because we do pre-bundle the cordova core plugins, as you can see here. Somethings up!

It seems that device plugin should work. Currently, I use CADT from pre-built .apk, so I will install it from the repo and check whether device plugin works for me.

So generally speaking, you cannot install a 3rdparty plugin and have it work with the CADT that we publish. You could, however, build your own CADT with the plugin added.

I will try to do that when I will need sophisticated plugins, however, the option to upload it dynamically would be fabulous! :)

If you want optional plugins, you're in cordova development land now and should be pushing assets "the cordova way" which I believe includes the plugins/PLATFORM.json file as part of the push, right?

I don't know if I got it, however, plugins/PLATFORM.json doesn't take part in the push process. I will install CADT from the repo and check it once again.

Either we add a flag to cca push to just default to this way when you're inside a cordova workspace?

Any additional flag concerning this problem would be appreciated.

In general, I need the funcitonality of adding plugins and pushing them by cca push, because relaunching of the application by cca push is much faster than by cca run. A fast development is really important, especially that I work on HTC Desire C, which is quite slow device.

Really thank you guys for your help :)

ghost commented 9 years ago

Unfortunately, I cannot install CADT from the repo. I think that it is connected to this issue: https://github.com/MobileChromeApps/chrome-app-developer-tool/issues/28

Pre-built .apk doesn't contain all plugins, so currently, the only solution is to push plugins dynamically, however I don't know how to do that.