2
我正在開發一個cordova插件。在這個插件中,我使用庫org.apache.http.legacy
。我成功地將這個庫複製到我的lib文件夾中。但我需要在我的build.gradle文件中寫入useLibrary 'org.apache.http.legacy'
。在android cordova插件中添加「useLibrary」到build.gradle
我該怎麼做?
我的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'
}
但沒有奏效。順便說一句,框架標籤也不起作用。
有沒有人有解決方案?
我有同樣的問題,你找到了解決方案嗎? – 23tux
我認爲這是我剛發佈的解決方案。希望能幫助到你。祝你好運! –