Phonegap build 只允许 html5、css 文件。正如您提到的,不支持 .java 文件。因此,如果您想构建您的 android 应用程序,您需要在 eclipse 中构建它,然后它也会使用 paypal 插件打包您的 html 代码。
从这里下载 phonegap 库
随附的是示例项目,它也可以指导您了解 android 的结构和休息,您可以在此处查找文档
在 plugins.xml 文件中定义插件,如下面的示例所示。
<config-file target="res/xml/config.xml" parent="/cordova/plugins">
<plugin name="ChildBrowser"
value="com.phonegap.plugins.childBrowser.ChildBrowser"/>
</config-file>
<source-file src="src/android/ChildBrowser.java"
target-dir="src/com/phonegap/plugins/childBrowser" />
这是我的 plugins.xml 文件之一,供您参考。
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.phonegap.plugins.childbrowser"
version="3.0.4">
<name>Child Browser</name>
<asset src="www/childbrowser.js" target="childbrowser.js" />
<asset src="www/childbrowser" target="childbrowser" />
<!-- android -->
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="com.phonegap.plugins.childBrowser.ChildBrowser"
android:label="@string/app_name">
<intent-filter>
</intent-filter>
</activity>
</config-file>
<!-- Cordova 1.5 - 1.9 -->
<config-file target="res/xml/plugins.xml" parent="/plugins">
<plugin name="ChildBrowser"
value="com.phonegap.plugins.childBrowser.ChildBrowser"/>
</config-file>
<!-- Cordova 2.0.0 -->
<config-file target="res/xml/config.xml" parent="/cordova/plugins">
<plugin name="ChildBrowser"
value="com.phonegap.plugins.childBrowser.ChildBrowser"/>
</config-file>
<source-file src="src/android/ChildBrowser.java"
target-dir="src/com/phonegap/plugins/childBrowser" />
</platform>
<!-- ios -->
<platform name="ios">
<plugins-plist key="ChildBrowser"
string="ChildBrowserCommand" />
<resource-file src="ChildBrowser.bundle" />
<resource-file src="ChildBrowserViewController.xib" />
<header-file src="ChildBrowserCommand.h" />
<header-file src="ChildBrowserViewController.h" />
<source-file src="ChildBrowserCommand.m" />
<source-file src="ChildBrowserViewController.m" />
</platform>
要添加的另一件事
包括在 config.xml 文件中的插件
<plugin name="MECLPayPalPlugin" value="com.phonegap.plugins.paypal.MECLPayPalPlugin"/>
如果您的项目中当前没有 plugins.xml 文件,请在 res/xml/plugins.xml 下创建它