编译Android PhoneGap插件

发布于 2024-12-11 01:12:37 字数 630 浏览 0 评论 0原文

我刚刚完成了一个测试插件的创建,我想将其编译到一个 jar 中以添加到我的 PhoneGap 项目中。有人可以举个例子吗?

我尝试运行这篇博文底部的命令(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

我更新了两个类路径并更新了我的Java文件;但是,当我运行该命令时,我收到一堆错误:

包 android.os 不存在 导入 android.os.Bundle;

使用解决方案编辑:

我不确定答案之一是否引导我走上这条路,我有点认为它确实如此,但我刚刚意识到 bin 目录已经包含所有编译为相同的 *.class 文件运行 javac,因此要创建 jar,我只需运行以下命令:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

皓月长歌 2024-12-18 01:12:37

更简单的是使用适用于 Eclipse 的 AppLaud PhoneGap 插件,该插件在 ADT 插件之上运行。该插件支持原生 Android Java 和 PhoneGap JavaScript。请参阅此处的 PhoneGap Wiki

不需要额外的 jar 文件,但您可以使用额外的配置来创建一个。

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.

空城缀染半城烟沙 2024-12-18 01:12:37

我能够通过执行以下操作找到解决方案:

我不确定答案之一是否引导我走上这条路,我认为它确实如此,但我刚刚意识到 bin 目录已经包含所有 *.类文件的编译方式与运行 javac 相同,因此要创建 jar,我只需运行以下命令:

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

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

浅笑轻吟梦一曲 2024-12-18 01:12:37

我认为最简单的方法是使用 Eclipse 和 Android SDK 插件。他们会自动为您编译它,您只需按一下按钮即可运行它。

您可以从 适用于 Eclipse 的 ADT 插件 获取该插件。完成此操作后,您就可以通过 Eclipse 中的 Android Manager 获取想要捆绑的相应 Android SDK 版本。

您可以在 PhoneGap Wiki 中找到详细信息

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文