-
n2nfadliLikes 1Problem Description
I have been facing this problem few days now with this log:
04-29 10:53:46.490: E/ActivityThread(21514): Failed to find provider info for com.facebook.katana.provider.PlatformProvider 04-29 10:53:46.492: E/ActivityThread(21514): Failed to find provider info for com.facebook.wakizashi.provider.PlatformProvider 04-29 10:53:46.557: E/AndroidRuntime(21514): FATAL EXCEPTION: GLThread 1587 04-29 10:53:46.557: E/AndroidRuntime(21514): Process: com.test.game, PID: 21514 04-29 10:53:46.557: E/AndroidRuntime(21514): com.facebook.FacebookException: Attempted to use a Session that was not open. 04-29 10:53:46.557: E/AndroidRuntime(21514): at com.facebook.widget.WebDialog$BuilderBase.<init>(WebDialog.java:524) 04-29 10:53:46.557: E/AndroidRuntime(21514): at com.facebook.widget.WebDialog$FeedDialogBuilder.<init>(WebDialog.java:708) 04-29 10:53:46.557: E/AndroidRuntime(21514): at sonar.systems.frameworks.Facebook.Facebook.Share(Facebook.java:151) 04-29 10:53:46.557: E/AndroidRuntime(21514): at sonar.systems.framework.SonarFrameworkFunctions.FacebookShare(SonarFrameworkFunctions.java:824) 04-29 10:53:46.557: E/AndroidRuntime(21514): at org.cocos2dx.lib.Cocos2dxRenderer.nativeTouchesEnd(Native Method) 04-29 10:53:46.557: E/AndroidRuntime(21514): at org.cocos2dx.lib.Cocos2dxRenderer.handleActionUp(Cocos2dxRenderer.java:120) 04-29 10:53:46.557: E/AndroidRuntime(21514): at org.cocos2dx.lib.Cocos2dxGLSurfaceView$8.run(Cocos2dxGLSurfaceView.java:245) 04-29 10:53:46.557: E/AndroidRuntime(21514): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462) 04-29 10:53:46.557: E/AndroidRuntime(21514): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
The first two lines are because I dont have Facebook app installed on my device.
The problem is at com.facebook.FacebookException: Attempted to use a Session that was not open.
And then crashes my game.
Solution DescriptionI add the solution here so that people that faced the same problem and searched the forum like I did, can stumble this for reference.
I found the solution from http://stackoverflow.com/a/25997039
Below is what I did to fix the Facebook.java inside sonar.systems.frameworks.Facebook.Facebook.java
@Override public void Share(String name, String link, String description, String caption, String imagePath) { final String shareName = name; final String shareLink = link; final String shareDescription = description; final String shareCaption = caption; final String shareImagePath = imagePath; // Check for session available or not, if not force open the session before sharing. if (Session.getActiveSession() == null || !Session.getActiveSession().isOpened()) { Session.openActiveSession(activity, true, new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { if (state.isOpened()) { publishFeedDialog(shareName, shareLink, shareDescription, shareCaption, shareImagePath); } } }); } else { publishFeedDialog(name, link, description, caption, imagePath); } }
publishFeedDialog is just the same code.
private void publishFeedDialog(String name, String link, String description, String caption, String imagePath) { if (FacebookDialog.canPresentShareDialog(activity.getApplicationContext(), FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) { // Publish the post using the Share Dialog FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(activity).setName(name). setDescription(description). setLink(link).build(); uiHelper.trackPendingDialogCall(shareDialog.present()); } else { // Fallback. For example, publish the post using the Feed Dialog Bundle params = new Bundle(); params.putString("name", name); // params.putString("caption",caption); params.putString("description", description); params.putString("link", link); //params.putString("picture", imagePath); try { WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(activity, Session.getActiveSession(), params)) .setOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { if (error == null) { // When the story is posted, echo the success // and the post Id. final String postId = values.getString("post_id"); if (postId != null) { Toast.makeText(activity, "Posted story, id: "+postId, Toast.LENGTH_SHORT).show(); } else { // User clicked the Cancel button Toast.makeText(activity.getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show(); } } else if (error instanceof FacebookOperationCanceledException) { // User clicked the "x" button Toast.makeText(activity.getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show(); } else { // Generic, ex: network error Toast.makeText(activity.getApplicationContext(), "Error posting story", Toast.LENGTH_SHORT).show(); } } }).build(); feedDialog.show(); } catch(FacebookException error) { Log.e(TAG, String.format("Error: %s", error.toString())); Handler h = new Handler(Looper.getMainLooper()); h.post(new Runnable() { public void run() { Toast.makeText(activity.getApplicationContext(), "Unable to post to Facebook.", Toast.LENGTH_SHORT).show(); } }); } }
I added FacebookException catch to show a Toast and prevent the crashes before I did the solution above.
Hope that helps.
-
Sonar Systems adminLikes 0
Thanks for sharing this :D
This reply has been verified.
-
Sonar Systems adminLikes 0
:D:D:D:D
This reply has been verified.
Login to reply