0

I am trying to integrate latest facebook android sdk(v 4.5) Like button. This is what I have put in my facebook_layout.xml

<com.facebook.share.widget.LikeView
            android:layout_marginTop="30dp"
            android:id="@+id/like_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center">
</com.facebook.share.widget.LikeView>

And I have a fragment where I am putting this like view onCreate method to initialize the view

LikeView likeView = (LikeView)facebookview.findViewById(R.id.like_view);
likeView.setEnabled(true);
likeView.setLikeViewStyle(LikeView.Style.BOX_COUNT);
likeView.setObjectIdAndType(
"https://www.facebook.com/FacebookDevelopers",
LikeView.ObjectType.PAGE);

Apart from this I have also put my app id in AndroidManifest.xml as mentioned here

But I am still not able to get the like to work. When I Click on the like button it just opens up a black facebook activity and for few seconds and closes it, and there are no likes happening on this page or the same page i have created for testing.

imgame
  • 1
  • 3
  • Are you able to repro this on the latest SDK with one of the bundled samples? if so, have you tried different user accounts and devices? – ifaour Sep 07 '15 at 13:45
  • I am using maven repository for the SDK dependency in gradle and 4.5 is the latest version there. I have tried it with bundled samples as well. And yes i have tried with multiple user accounts and with multiple devices- namely Nexus 5(v5.1.1) and MotoE(v 4.4.4) and Nexus 4(API 19) emulator. I have also raised the issue on developer.facebook.com https://developers.facebook.com/bugs/125374871144350 – imgame Sep 07 '15 at 14:27
  • I'm handling your bug report on Facebook side :), let's continue the discussion there and if this turned to be a bug you can post the bug after confirming the bug (if any) – ifaour Sep 10 '15 at 14:05
  • I am also experiencing the same issue, did you @imgame get any workaround. – Gopal Aug 25 '16 at 06:34

1 Answers1

1

I have resolved this issue by adding my facebook user as a Tester/Developer to my facebook android App.

Reference: https://developers.facebook.com/docs/apps/security

Note: you can set the error listener to the object of LikeView for the better understanding of what error you are getting.

likeView.setOnErrorListener(new LikeView.OnErrorListener() {
        @Override
        public void onError(FacebookException e) {
            Log.e(TAG, e.getMessage(), e);
        }
    });
Gopal
  • 1,734
  • 1
  • 14
  • 34