当我在我们的应用程序中使用Facebook登录时,我遇到了问题。有时我签名,它会因此错误而崩溃。我搜索了类似的排名,但不太了解。
java.lang.IllegalArgumentException:Service not registered: com.facebook.login.GetTokenClient@1ab2a49b
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1110)
at android.app.ContextImpl.unbindService(ContextImpl.java:2190)
at android.content.ContextWrapper.unbindService(ContextWrapper.java:571)
at com.facebook.internal.PlatformServiceClient.handleMessage(PlatformServiceClient.java:145)
at com.facebook.internal.PlatformServiceClient$1.handleMessage(PlatformServiceClient.java:62)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6141)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
这是我的代码:initLogin()
方法中的onCreate()
private void initLogin() {
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(final LoginResult loginResult) {
String mToken = loginResult.getAccessToken().getToken();
if(!TextUtils.isEmpty(mToken)){
GraphRequest graphRequest = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
if (response.getError() != null) {
Log.d(TAG, "FB: parse info error!");
onLoginFail(Constants.LOGIN_FACEBOOK);
} else {
LogHelper.d(TAG, "Object:" + object.toString() + ",Response:" + response);
loginPresenter.startLoginFacebook( loginResult.getAccessToken().getToken(),
object.optString("id"), object.optString("name"),
object.optString("picture"), object.optString("email"));
}
}
});
Bundle mParameters = new Bundle();
mParameters.putString("fields", "id,name,email,gender,picture,birthday");
graphRequest.setParameters(mParameters);
graphRequest.executeAsync();
}else {
onfailed();
}
}
@Override
public void onCancel() {
LogHelper.d(TAG,"User cancel to login FB。");
}
@Override
public void onError(FacebookException exception) {
onfailed();
}
private void onfailed() {
ToastUtil.showToast(getApplicationContext(), R.string.footer_net_error);
}
});
我发现Facebook类PlatformServiceClient在这里有一个null结果:
protected abstract void populateRequestBundle(Bundle data);
protected void handleMessage(Message message) {
if (message.what == replyMessage) {
Bundle extras = message.getData();
String errorType = extras.getString(NativeProtocol.STATUS_ERROR_TYPE);
if (errorType != null) {
callback(null);
} else {
callback(extras);
}
context.unbindService(this);
}
}
额外内容为空。
有人可以帮助我吗?谢谢。