2

我是 PhoneGap 和移动 Paypal 的新手。我在我的 PhoneGap 应用程序中尝试了https://github.com/azicchetti/MECLPayPalPlugin插件,并且在模拟器上运行良好。

现在我想发送到 PhoneGap Build 以在真实手机中进行测试。但是根据 Phonegap Build doc,如果我们上传像 .java 这样的原生文件,我们的应用程序很可能无法编译。那么,当我需要发布我的应用程序时,如何在此插件中将 Paypal 服务器更改为 live 和应用程序 ID?

谢谢!

4

1 回答 1

2

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 下创建它

于 2012-11-19T02:58:43.813 回答