2

我正在尝试集成 Pinterest 以共享博客/创建 pin。我正在按照官方文档tutorial1tutorial2 来集成 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'
}

我的app模块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'
}

我尝试从中访问 pdk 的登录方法的 PinterestApi 类。

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 源代码

4

2 回答 2

1

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

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

或者我认为您应该在应用程序的 build.gradle 中添加 volley

于 2018-09-22T10:47:18.063 回答
0

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

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

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

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

于 2018-09-22T10:51:05.837 回答