Question

I've just finished creating a test plugin and I would like to compile it into a jar to add to my PhoneGap project. Can someone provide an example?

I tried running the commands at the bottom of this blog post (http://kgriff.posterous.com/building-a-phonegap-plugin-for-android)

javac -d . -classpath <path_to_your>/android.jar:<path_to_your>phonegap.jar com/yourpackage/ToastPlugin.java

I updated the two classpath's as well as updated my Java file; however, when I run the command I receive a bunch of errors:

package android.os does not exist import android.os.Bundle;

Edit with solution:

I'm not sure if one of the answers led me down this path, I kind of think it did, but I just realized that the bin directory already contains all of the *.class files that get compiled the same as running javac, so to create the jar, I just had to run this command:

jar -cvf myplugin.jar com\path\plugin\*.class
Was it helpful?

Solution 2

I was able to find the solution by doing the following:

I'm not sure if one of the answers led me down this path, I kind of think it did, but I just realized that the bin directory already contains all of the *.class files that get compiled the same as running javac, so to create the jar, I just had to run this command:

jar -cvf myplugin.jar com\path\plugin\*.class

OTHER TIPS

Even easier is using the AppLaud PhoneGap Plug-in for Eclipse which runs on top of the ADT plugin. The plugin supports both native Android Java and PhoneGap JavaScript. See the PhoneGap Wiki here.

There is no need for an additional jar file, but you could make one with additional configuration.

I think the easiest is to use Eclipse with Android SDK plugin. They will compile it for you automatically and you could run it with a push of a button.

You can the plugin from ADT Plugin for Eclipse. Once you do that, you could get the appropriate Android SDK version that you want to bundle it via Android Manager in Eclipse.

You could find the details in the PhoneGap Wiki

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top