Volley Android - 无法解析符号' ClientError'

时间:2017-07-18 09:12:26

标签: java android json android-volley jsonobjectrequest

我试图将此代码https://github.com/smanikandan14/Volley-demo/blob/master/volleydemoapp/src/main/java/com/mani/volleydemo/JSONObjectRequestActvity.java改编为我自己的项目。

当我尝试制作JSONObjectResponse

jsonObjRequest = new JsonObjectRequest(Request.Method.GET, builder.toString(), null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            try {
                parseFlickrImageResponse(response);
                mAdapter.notifyDataSetChanged();
            } catch (Exception e) {
                e.printStackTrace();
                showToast("JSON parse error");
            }
            stopProgress();
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            // Handle your error types accordingly.For Timeout & No connection error, you can show 'retry' button.
            // For AuthFailure, you can re login with user credentials.
            // For ClientError, 400 & 401, Errors happening on client side when sending api request.
            // In this case you can check how client is forming the api and debug accordingly.
            // For ServerError 5xx, you can do retry or handle accordingly.
            if( error instanceof NetworkError) {
            } else if( error instanceof ClientError) {
            } else if( error instanceof ServerError) {
            } else if( error instanceof AuthFailureError) {
            } else if( error instanceof ParseError) {
            } else if( error instanceof NoConnectionError) {
            } else if( error instanceof TimeoutError) {
            }

            stopProgress();
            showToast(error.getMessage());
        }
    });

但是出现了这个错误:

Cannot resolve symbol 'ClientError'

我试图以多种方式输入截击,但它们似乎都没有效果。 (.jar,compile&#39; com.android.volley:volley:1.0.0&#39 ;, compile&#39; com.mcxiaoke.volley:library:1.0.19&#39;等)。

顺便说一下,我使用的是Android Studio。

编辑:

我的傻瓜

apply plugin: 'com.android.application'

android {     compileSdkVersion 25     buildToolsVersion&#34; 25.0.2&#34;

defaultConfig {
    applicationId "com.tigerspike.interview.oriolgarcia.tigerspickr"
    minSdkVersion 17
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.volley:volley:1.0.0'
}

0 个答案:

没有答案