我正在开发一个cordova插件。在这个插件中,我使用库org.apache.http.legacy
。我在我的lib文件夹中成功复制了这个库。但我需要在build.gradle文件中编写useLibrary 'org.apache.http.legacy'
。
我该怎么做?
我的plugin.xml:
[...]
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="DownloaderActivity" android:launchMode="singleTop" android:name="[pluginPath].DownloaderActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustPan">
</activity>
<service android:name="[pluginPath].DownloaderService" />
<receiver android:name="d[pluginPath].DownloaderServiceBroadcastReceiver" />
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
</config-file>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="ExpansionFileReader">
<param name="android-package" value="[pluginPath].ExpansionFileReader" />
</feature>
</config-file>
<source-file src="src/android/ExpansionFileReader.java" target-dir="src/de/[path]/cordova/plugin" />
<source-file src="src/android/expansion" target-dir="src/de/[path]/cordova/plugin" />
<source-file src="src/android/zipfile" target-dir="src/de/[path]/cordova/plugin" />
<source-file src="src/com" target-dir="src" />
<source-file src="src/android/org.apache.http.legacy.jar" target-dir="libs" framework="true" />
<framework src="com.google.http-client:google-http-client-android:+" />
<framework src="com.google.api-client:google-api-client-android:+" />
<framework src="com.google.api-client:google-api-client-gson:+" />
<framework src="com.google.code.gson:gson:2.2.4" />
</platform>
[...]
我尝试使用<framework src="src/gradle/buildExtension.gradle" custom="true" type="gradleReference" />
,buildExtension.gradle
包含
android {
useLibrary 'org.apache.http.legacy'
}
但它没有用。顺便说一句,框架标签也不起作用。
有人有解决方案吗?
答案 0 :(得分:1)
这可能是解决方案:
我添加了一个build-extras.gradle文件,它添加了gradle部分:
plugin.xml中:
[...]
<source-file src="src/android/ExpansionFileReader.java" target-dir="src/de/projektionisten/cordova/plugin" />
<source-file src="src/android/expansion" target-dir="src/de/projektionisten/cordova/plugin" />
<source-file src="src/android/zipfile" target-dir="src/de/projektionisten/cordova/plugin" />
<source-file src="src/com" target-dir="src" />
<source-file src="src/android/build-extras.gradle" target-dir="CordovaLib" />
<source-file src="src/android/org.apache.http.legacy.jar" target-dir="libs" framework="true" />
<framework src="src/android/build-extras.gradle" custom="true" type="gradleReference" />
[...]
积extras.gradle:
android {
useLibrary 'org.apache.http.legacy'
}