سؤال

I'm writing a Plugman-compatible Cordova plugin. Installing it via Plugman, I've confirmed it installs correctly and runs normally:

plugman --platform android --project /platforms/android --plugin my/plugin.path

But if I use:

cordova build/cordova run android

it doesn't work even with plugin installed. This is because Plugman only installs my plugin js file to the /platforms/android/assets/www folder and not the base /www folder, so when I build, the /www folder without the plugin gets copied to /platforms/android/assets/www.

Is there an option or something in plugin.xml I should be specifying to install the plugin to the project root www folder?

هل كانت مفيدة؟

المحلول

When using Cordova CLI, you shouldn't install plugins using plugman. Cordova CLI does use plugman under the covers, but what you want to use is cordova plugins add http://... or cordova plugins add /path/to/plugin.xml.

You didn't specify which version of Cordova you are using, but here's some examples of adding plugins that are core functionality: http://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface

نصائح أخرى

It should put the js files in platforms/android/assets/www/plugins/com.plugin-name/www and the java files in platforms/android/src/com/plugin-name/

You can specify this in the plugin.xml file like this (this is an example from a plugin that I upgraded to https://github.com/aharris88/phonegap-sms-plugin3.0 ()):

<js-module src="www/sms.js" name="Sms">
    <clobbers target="window.sms" />
</js-module>

<!-- android -->
<platform name="android">
    <config-file target="res/xml/config.xml" parent="/*">
        <feature name="Sms">
            <param name="android-package" value="com.adamwadeharris.sms.Sms"/>
        </feature>
    </config-file>

    <config-file target="AndroidManifest.xml" parent="/manifest">
        <uses-permission android:name="android.permission.SEND_SMS" />
    </config-file>

    <source-file src="src/android/Sms.java" target-dir="src/com/adamwadeharris/sms" />
</platform>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top