Pinterest sdk callback class error: cannot access Response class file for com.android.volley.Response not found

Pinterest sdk callback class error: cannot access Response class file for com.android.volley.Response not found

我正在尝试整合 Pinterest 以分享 blog/creating 一个图钉。我正在关注 the official documentation, tutorial1 and tutorial2 以整合 Pinterest。 但是,问题是当我尝试授权用户并将 PDKCallback 对象传递到登录方法时,如下所示,

    pdkClient.login(this, scopes, new PDKCallback() {
            @Override
           public void onSuccess(PDKResponse response) {
                Log.d(getClass().getName(), response.getData().toString());
                //user logged in, use response.getUser() to get PDKUser object
            }

            @Override
            public void onFailure(PDKException exception) {
               Log.e(getClass().getName(), exception.getDetailMessage());
          }
        });

它向我显示了以下 编译 错误

cannot access Response class file for com.android.volley.Response not found

谁能帮我解决这个问题?

编辑

我的pdk模块gradle文件如下:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
//   implementation 'com.android.support:appcompat-v7:21.0.3'
    implementation 'com.android.volley:volley:1.1.1'
//    implementation 'com.mcxiaoke.volley:library:1.0.19'
}

我的应用模块build.gradle文件的依赖如下

dependencies {

implementation('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') 
 {
        transitive = true
    }

    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.google.code.gson:gson:2.8.4'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'com.firebase:firebase-client-android:2.4.0'
    implementation 'com.plattysoft.leonids:LeonidsLib:1.3.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'

    implementation project(':wScratchViewLibrary')
    implementation project(':linkedin-sdk')
    implementation project(':pdk')

    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.3.0'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.j256.ormlite:ormlite-android:4.48'
    implementation 'com.j256.ormlite:ormlite-core:4.48'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.google.android.gms:play-services-vision:15.0.2'
    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'com.google.android.gms:play-services-plus:15.0.1'

    implementation 'com.facebook.android:facebook-share:4.33.0'
    implementation ('com.twitter.sdk.android:twitter:3.3.0@aar') {
        transitive = true
    }

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.github.amlcurran.showcaseview:library:5.4.3'

    implementation "com.mixpanel.android:mixpanel-android:5.4.1"
    implementation "com.google.android.gms:play-services-gcm:15.0.1"
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
    implementation 'com.wang.avi:library:2.1.3'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.0'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    implementation files('libs/nineoldandroids-library-2.4.0.jar')

    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
    implementation 'com.github.cooltechworks:ScratchView:v1.1'
}

我的 PinterestApi class 我试图从中访问 pdk 的登录方法。

package com.veriloginqr.android.sharing_apis;

import android.content.Context;
import android.util.Log;

import com.pinterest.android.pdk.PDKCallback;
import com.pinterest.android.pdk.PDKClient;
import com.pinterest.android.pdk.PDKException;
import com.pinterest.android.pdk.PDKResponse;

import java.util.ArrayList;
import java.util.List;

public class PinterestApi {

    private static final String appID = "my_app_id_i_wont_reveal";

    private PDKClient pdkClient;

    private Context context;

    public PinterestApi(Context context) {
        this.context=context;

        // Call configureInstance() method with context and App Id
        pdkClient = PDKClient.configureInstance(context, appID);

        // Call onConnect() method to make link between App id and Pinterest SDK
        pdkClient.onConnect(context);
        PDKClient.setDebugMode(true);

    }


    public void authorizeUser(){

        List<String> scopes = new ArrayList<>();
        scopes.add(PDKClient.PDKCLIENT_PERMISSION_READ_PUBLIC);
        scopes.add(PDKClient.PDKCLIENT_PERMISSION_WRITE_PUBLIC);

        pdkClient.login(context,scopes,new PDKCallback(){
            @Override
            public void onSuccess(PDKResponse response) {
                Log.d(getClass().getName(), response.getData().toString());
                //user logged in, use response.getUser() to get PDKUser object
            }

            @Override
            public void onFailure(PDKException exception) {
                Log.e(getClass().getName(), exception.getDetailMessage());
            }
        });

    }

}

Note: You can check the pdk source code here.

尝试像这样将 volley 版本从 1.0.0 更改为 1.0.1

implementation 'com.android.volley:volley:1.1.1'

或者我认为您应该在应用的 build.gradle

中添加 volley

导入和代码似乎没问题。问题似乎不是下载整个依赖项,也不是在构建需要重建清理项目时出现问题。

解决方案将使用最新版本:

implementation 'com.android.volley:volley:1.1.1' 

并确保未在“设置”中选中离线工作。