我正在使用Facebook-Parse
进行小型测试Android项目。它托管在heroku
。
我觉得我遇到了错误,因为Retrofit
& Facebook-Parse
不能在一起玩得很好。
我的build.gradle
文件:
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'android-apt'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.sudhishkr.project.test"
minSdkVersion 23
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
// parse stuff
compile 'com.parse:parse-android:1.13.1'
compile 'com.parse:parseinterceptors:0.0.2'
compile 'com.parse.bolts:bolts-android:1.4.0'
// butterknife
apt 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.jakewharton:butterknife:8.4.0'
//
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
//
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'jp.wasabeef:picasso-transformations:2.1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
//
compile 'com.squareup.okhttp3:okhttp:3.3.0'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.google.code.gson:gson:2.6.2'
}
我正在使用Facebook-Parse仅用于与用户相关的操作。我对登录页面有疑问。
这是我的登录片段
public class LoginFragment extends Fragment {
@BindView(R.id.etEmail) EditText etEmail;
@BindView(R.id.etPassword) EditText etPassword;
@BindView(R.id.btnLogIn) Button btnLogIn;
@BindView(R.id.btnSignUp) Button btnSignUp;
private Unbinder unbinder;
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_login, container, false);
unbinder = ButterKnife.bind(this, view);
btnLogIn.setOnClickListener(v -> ParseUser.logInInBackground(etEmail.getText().toString(),
etPassword.getText().toString(),
(user, e) -> {
if (user != null) {
GeneralUtils.showSnackBar(getView(),
"Success",
getActivity().getColor(R.color.colorGreen),
getActivity().getColor(R.color.colorGray));
Intent intent = new Intent(getActivity(), HomeActivity.class);
startActivity(intent);
} else {
GeneralUtils.showSnackBar(getView(),
"Failed",
getActivity().getColor(R.color.colorRed),
getActivity().getColor(R.color.colorGray));
}
}));
btnSignUp.setOnClickListener(v -> {
Intent intent = new Intent(getActivity(), SignupActivity.class);
startActivity(intent);
});
return view;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
}
现在使用此设置,我无法在Facebook-Parse
后端的现有用户上执行登录。我得到的错误是:com.parse.ParseException: java.lang.NullPointerException: value == null
现在,如果我从build.gradle
文件中删除以下部分,并尝试使用现有用户登录。我能够毫无问题地通过。
compile 'com.squareup.okhttp3:okhttp:3.3.0'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.google.code.gson:gson:2.6.2'
我真的很喜欢将retrofit
用于我的项目,而且我不确定这个问题的根本原因。这必须是我想念的小东西或者非常大的东西。
我很乐意提供有关此问题的更多详细信息。请告诉我。
修改
提供stacktrace
12-05 01:28:26.334 9197-9403/com.sudhishkr.project.test E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f88096824d0
12-05 01:28:39.661 9197-9197/com.sudhishkr.project.test W/System.err: com.parse.ParseException: java.lang.NullPointerException: value == null
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:114)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at android.os.Looper.loop(Looper.java:148)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at java.lang.reflect.Method.invoke(Native Method)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: Caused by: java.lang.NullPointerException: value == null
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:316)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at okhttp3.Headers$Builder.add(Headers.java:270)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseOkHttpClient.getRequest(ParseOkHttpClient.java:138)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseOkHttpClient.executeInternal(ParseOkHttpClient.java:64)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:158)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseDecompressInterceptor.intercept(ParseDecompressInterceptor.java:30)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:147)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParsePlugins$1.intercept(ParsePlugins.java:115)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:147)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseHttpClient.execute(ParseHttpClient.java:122)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:136)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:133)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at bolts.Task$15.run(Task.java:917)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at bolts.Task.completeAfterTask(Task.java:908)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at bolts.Task.continueWithTask(Task.java:715)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at bolts.Task.continueWithTask(Task.java:726)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at bolts.Task$13.then(Task.java:818)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at bolts.Task$13.then(Task.java:806)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at bolts.Task$15.run(Task.java:917)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test W/System.err: at java.lang.Thread.run(Thread.java:818)
12-05 01:28:39.662 9197-9197/com.sudhishkr.project.test E/sudhishkrError: java.lang.NullPointerException: value == null