Я начал разработку ионного плагина для выполнения http-звонков с использованием библиотеки Volley.Я создал файл .gradle и добавил зависимость залпа.Реализовал свои методы в java файле.Затем добавил этот плагин в проект ioinc. Но когда я создаю свое приложение, оно выдает мне следующую ошибку.
BUILD FAILED in 30s
FAILED
27 actionable tasks: 7 executed, 20 up-to-date
(node:28436) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
D:\JalBharat\mobile\v2\plugins\ionic-check-network-connectivity\platforms\android\app\src\main\java\http-client\HttpClient\HttpClient.java:12: error: package com.android.volley.error does not exist
import com.android.volley.error.VolleyError;
^
D:\JalBharat\mobile\v2\plugins\ionic-check-network-connectivity\platforms\android\app\src\main\java\http-client\HttpClient\HttpClient.java:13: error: package com.android.volley.request does not exist
import com.android.volley.request.JsonObjectRequest;
^
D:\JalBharat\mobile\v2\plugins\ionic-check-network-connectivity\platforms\android\app\src\main\java\http-client\HttpClient\HttpClient.java:14: error: package com.android.volley.request does not exist
import com.android.volley.request.StringRequest;
^
D:\JalBharat\mobile\v2\plugins\ionic-check-network-connectivity\platforms\android\app\src\main\java\http-client\HttpClient\HttpClient.java:44: error: cannot find symbol
RequestQueue queue = Volley.newRequestQueue(this);
^
symbol: class RequestQueue
location: class HttpClient
D:\JalBharat\mobile\v2\plugins\ionic-check-network-connectivity\platforms\android\app\src\main\java\http-client\HttpClient\HttpClient.java:44: error: cannot find symbol
RequestQueue queue = Volley.newRequestQueue(this);
^
symbol: variable Volley
location: class HttpClient
D:\JalBharat\mobile\v2\plugins\ionic-check-network-connectivity\platforms\android\app\src\main\java\http-client\HttpClient\HttpClient.java:47: error: cannot find symbol
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
^
symbol: class StringRequest
location: class HttpClient
D:\JalBharat\mobile\v2\plugins\ionic-check-network-connectivity\platforms\android\app\src\main\java\http-client\HttpClient\HttpClient.java:47: error: cannot find symbol
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
^
symbol: class StringRequest
location: class HttpClient
D:\JalBharat\mobile\v2\plugins\ionic-check-network-connectivity\platforms\android\app\src\main\java\http-client\HttpClient\HttpClient.java:56: error: cannot find symbol
public void onErrorResponse(VolleyError error) {
^
symbol: class VolleyError
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
8 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
D:\JalBharat\mobile\v2\plugins\ionic-check-network-connectivity>
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 30s
(node:28436) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
^
Что я понял из этой ошибки, так это то, что библиотека Volley не импортируется.Здесь я прилагаю свои файлы плагинов.Пожалуйста, помогите мне.
plugin.xml
<?xml version="1.0" encoding="utf-8"?>
<plugin id="http-client" version="0.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>
HttpClient
</name>
<js-module name="HttpClient" src="www/HttpClient.js">
<clobbers target="HttpClient" />
</js-module>
<platform name="android">
<config-file parent="/*" target="res/xml/config.xml">
<feature name="HttpClient">
<param name="android-package" value="http.client.HttpClient" />
</feature>
</config-file>
<framework src="src/android/http-client-plugin.gradle" custom="true" type="gradleReference"/>
<framework src="com.android.support:support-v4:$ANDROID_SUPPORT_V4_VERSION"/>
<!-- <lib-file src="src/android/com.android.volley:volley:1.1.1.aar"/> -->
<preference name="ANDROID_SUPPORT_V4_VERSION" default="27.+"/>
<config-file parent="/*" target="AndroidManifest.xml">
</config-file>
<source-file src="src/android/HttpClient.java" target-dir="src/http-client/HttpClient" />
</platform>
</plugin>
http-client-plugin.gradle
repositories{
jcenter()
flatDir{
dirs 'libs'
}
}
dependencies {
compile 'com.android.volley:volley:1.1.1'
}
android {
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}