RandomEli
RandomEli

Reputation: 1557

How to add third party plugins in my cordova plugin?

I am developing a cordova plugin and I want to publish now. However, I need to invoke some third party plugins in my plugin, such as cordova-plugin-camera and cordova-plugin-googlemaps. Currently I'm merging everything and given source path in plugin.xml manually, which is a poor code management. I want to know if I can add the dependencies in plugin.xml and free my work.

Upvotes: 0

Views: 391

Answers (1)

RandomEli
RandomEli

Reputation: 1557

Actually, I'm helping my friends to solve his problem. Read this Doc of plugin.xml. And specifically:

The <dependency> tag allows you to specify other plugins on which the current plugin depends. The plugins are referenced by their unique npm ids or by github url.

Therefore, what you should do is simple:

<dependency id="cordova-plugin-camera" version="^1.1.1" />

but be careful when you dealing with feature and permission in manifest.xml, if you still have those issues after addinig those dependencies, you need add them in plugin.xml as well:

<config-file target="res/xml/config.xml" parent="/*">
    <feature name="Camera">
        <param name="android-package" value="org.apache.cordova.camera.CameraLauncher"/>
    </feature>
</config-file>

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

Hopefully it will solve your problem.

Upvotes: 2

Related Questions