[英]Pinterest sdk callback class error: cannot access Response class file for com.android.volley.Response not found
I am trying to integrate Pinterest for sharing blog/creating a pin.我正在尝试集成 Pinterest 以共享博客/创建图钉。 I am following the official documentation , tutorial1 and tutorial2 to integrate the Pinterest.
我正在按照官方文档、 教程 1和教程 2来集成 Pinterest。 But, the issue is when I try to authorize the user and pass
PDKCallback
object into the login method as shown below,但是,问题是当我尝试授权用户并将
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());
}
});
It shows me the following compilation error它显示了以下编译错误
cannot access Response class file for com.android.volley.Response not found
无法访问 com.android.volley.Response 的响应类文件未找到
Can anybody help me with this problem?有人可以帮我解决这个问题吗?
Edit编辑
My pdk module gradle file is as follows:我的 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'
}
My app module build.gradle file's dependency is as follows我的应用模块 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'
}
My PinterestApi class from which I try to access the login method of pdk.我尝试从中访问 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());
}
});
}
}
Note: You can check the pdk source code here.
注意:您可以在此处查看 pdk 源代码。
try changing the volley version from 1.0.0 to 1.0.1 like this尝试像这样将 volley 版本从 1.0.0 更改为 1.0.1
implementation 'com.android.volley:volley:1.1.1'
or I think you should be adding volley in your app's build.gradle或者我认为您应该在应用程序的 build.gradle 中添加 volley
Imports & codes seems fine.进口和代码似乎没问题。 The issue seems to be not downloading the whole dependency nor, there was a problem when building which needs a rebuild-clean project.
问题似乎不是下载整个依赖项,也不是在构建需要重建清理项目时出现问题。
The solution will be using the latest version:该解决方案将使用最新版本:
implementation 'com.android.volley:volley:1.1.1'
And making sure offline work not checked in the Settings.并确保未在“设置”中选中离线工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.