ioinc插件未获取plugin.gradle文件

时间:2018-10-03 08:53:52

标签: android ionic3 cordova-plugins ionic-plugins

我开始开发离子插件,以使用Volley库进行http调用。我创建了一个.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'
    }
}

0 个答案:

没有答案