2012-11-19 32 views
2

我是PhoneGap和移動支付寶的新手。我在我的PhoneGap應用程序中嘗試了https://github.com/azicchetti/MECLPayPalPlugin插件,並且可以很好地使用模擬器。使用Java本機文件構建Phonegap

現在我想發送到PhoneGap構建測試在真實的手機。但根據Phonegap Build doc,如果我們上傳本地文件如.java,我們的應用很可能無法編譯。 那麼,當我需要發佈我的應用程序時,如何將Paypal服務器更改爲此插件中的live和app id?

謝謝!

回答

2

Phonegap build只允許html5,css文件。正如你所提到的.java文件不被支持。因此,如果你想構建你的android應用程序,你需要在eclipse中構建它,然後它會用你的貝寶插件打包你的html代碼。

here

;隨下載的PhoneGap庫是示例項目,並且可以指導你,以及對機器人的結構和休息,你可以查找here for the docs

在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下創建它

+0

嗨Diberted,謝謝你的回答。我試過所有你提到的那些步驟,如果我沒有實現MECL插件,它工作正常。但是,現在我需要它,並且需要將PayPal環境更改爲LIVE,但根據插件說明,我需要在Java文件中對其進行更改。那麼PhoneGap如何知道我是否不包含java文件?您創建的項目中包括 –

+0

,包括插件提供的.java文件,還有一個plugins.xml文件,它是項目的一部分,您需要在其中定義插件。看看答案(我已經添加了示例) – Dilberted

+0

我不確定是否真的必須在config.xml中輸入條目,但是我還在上面添加了該條目。 – Dilberted

相關問題