在cordova 3.4.0应用程序中添加外部Jar文件

时间:2014-04-01 06:27:30

标签: java android cordova

我正在为android创建两个自定义插件,使用我的plugin.xml中描述的这个插件。我的plugin.xml文件就像

    <?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id="com.my.mybiometric"
    version="1.2">

    <name>myBiometric</name>
    <description>myBiometric Plugin</description>
    <license>Apache 2.0</license>
    <keywords>media,upload</keywords>

<engines>
    <engine name="cordova-android" version=">=3.4.0" />
</engines>
    <js-module src="www/js/Media2.js" name="Media2">
        <clobbers target="mediaRec.startRecord" /> 
    </js-module>
    <js-module src="www/js/VoiceUpload.js" name="VoiceUpload">
         <clobbers target="VoiceUpload" />
    </js-module>

    <!-- android -->
    <platform name="android">
        <config-file target="res/xml/config.xml" parent="/*">
         <feature name="Media2">
    <param name="android-package" value="com.my.mybiometric.AudioHandler"/>
    </feature>
    <feature name="VoiceUpload">
      <param name="android-package" value="com.my.mybiometric.UploadHandler"/>
    </feature>
        </config-file>
        <config-file target="AndroidManifest.xml" parent="/manifest/application">
        <activity
            android:name="com.my.mybiometric.myBiometric"
            android:label="@string/app_name" 
            android:screenOrientation="portrait"
          android:configChanges="orientation|screenSize|keyboardHidden">
          </activity>
    </config-file>

        <source-file src="platforms/android/src/com/my/plugins/AudioHandler.java" target-dir="src/com/my/mybiometric" />
        <source-file src="platforms/android/src/com/my/plugins/UploadHandler.java" target-dir="src/com/my/mybiometric" />
        <source-file src="platforms/android/src/com/my/plugins/AppLog.java" target-dir="src/com/my/mybiometric" />
        <source-file src="platforms/android/src/com/my/plugins/MyResponseHandler.java" target-dir="src/com/my/mybiometric" />
        <source-file src="platforms/android/src/com/my/plugins/Recorder.java" target-dir="src/com/my/mybiometric" />

        <source-file src="platforms/android/src/com/my/plugins/VoiceBiometricClient.java" target-dir="src/com/my/mybiometric" />
        <source-file src="platforms/android/src/com/my/plugins/VoiceBiometricClientUsage.java" target-dir="src/com/my/mybiometric" />

     </platform>
</plugin>

构建并运行项目后,media2插件工作正常但是当我调用voiceupload插件时,它返回“类未找到”错误进行语音上传我正在使用“android-async-http -1.4.4.jar”。我将jar文件添加到我手动添加的libs文件夹中。 如何解决这个问题?

2 个答案:

答案 0 :(得分:4)

  1. 您将jar文件放在插件中的平台/ android / src / libs
  2. 在plugin.xml中添加行

    <source-file src="platforms/android/src/libs/android-async-http-1.4.4.jar" target-dir="libs" />

  3. no 3。

答案 1 :(得分:0)

检查我的回答here

您需要转到项目 - >&gt;属性并根据答案进行一些更改。

希望这有帮助。