Pinterest SDK回调类错误:无法访问com.android.volley.Response的响应类文件

时间:2018-09-22 10:32:23

标签: android android-volley pinterest pdk

我正在尝试整合Pinterest以共享博客/创建图钉。我正在关注the official documentationtutorial1tutorial2来整合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());
          }
        });

它显示了以下编译错误

  

无法访问com.android.volley.Response的响应类文件

有人可以帮助我解决这个问题吗?

修改

我的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类,尝试从中访问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());
            }
        });

    }

}
  

注意:您可以查看pdk源代码here.

2 个答案:

答案 0 :(得分:1)

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

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

或者我认为您应该在应用的build.gradle中添加排球

答案 1 :(得分:0)

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

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

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

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