Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Facebook Android Plugin — Gideros Forum

Facebook Android Plugin

ar2rsawseenar2rsawseen Maintainer
edited July 2013 in Step by step tutorials
Here is a Facebook Android Plugin.

https://github.com/ar2rsawseen/GiderosFacebookAndroidPlugin

It will probably be included in next versions of Gideros, but for those of you who can't wait and want to try it out now (maybe even find any bugs :) ) here it is.

I've attached two files, one (FacebookPlugin.zip) for Android exported project other (FacebookGideros.zip) a Gideros sample project.

Installation instructions:
  • Download Facebook SDK here: http://developers.facebook.com/android/
  • Facebook SDK installation instructions here: http://developers.facebook.com/android/
    • Download and unzip
    • Import SDK into eclipse (Note you need to import it in workspace and check copy all files)
  • Export Gideros project to Android project
  • Import Android project to eclipse (Note you need to import it in workspace and check copy all files or Facebook SDK won't work)
  • Link Facebook SDK to your project:
    • Right click on your project
    • Select properties
    • Choose Android
    • In library section click Add and choose FacebookSDK
    • If it's not there or not linking properly, it means that you haven't imported FacebookSDK into eclipse or it's not in your workspace or your project is not in your workspace
  • Copy contents of FacebookPlugin.zip into your project:
    • Copy .so files to each separate armeabi folder
    • Copy facebook folder to src/giderosmobile/android/plugins folder
  • Inside your main activity:
    • Add lib as System.loadLibrary("facebook");
    • Add external class as "com.giderosmobile.android.plugins.facebook.GFacebook"
    • Add this line inside onActivityResult method: GFacebook.fb.authorizeCallback(requestCode, resultCode, data); (This step will not be needed, when plugin will be included in Gideros SDK)
  • Clean and launch the app, if it does not work, come and complain here, because I may have also screwed something up :)

EDIT
Attaching Facebook SDK I used while developing plugin
+1 -1 (+12 / -0 )Share on Facebook
«1345

Comments

  • What exactly does it do with facebook?
    Like an app which posts to someone's page, or use their profile as a means of identification for a score table? Stuff like that?
  • ar2rsawseenar2rsawseen Maintainer
    Basically it can do all Graph API provides:
    http://developers.facebook.com/docs/reference/api/

    Additionally it uses Facebook app for authentication or provides Web Dialogs.

    And there are also other web dialogs as one that allows user to post something to his wall, etc. :)
  • Dear @ar2rsawseen
    I think I have found one bug:

    local score = 10
    local paramaters = {
    score = score,
    fields = "firstname"
    }
    facebook:graphRequest("me/scores", paramaters,"POST")

    This code closes player.
  • ar2rsawseenar2rsawseen Maintainer
    @achimeno thanks, I love when users provide test cases, I'll check it right now :)
  • Thank you @ar2rsawseen

    Another one:
    facebook:authorize({"publish_actions"})

    In the Java part you have a null in the String [] --> {"publish_actions", null}
  • Any way to make it works in Gideros Player? I'm just curious how to make something harder than authorizing and sharing without it.
  • ar2rsawseenar2rsawseen Maintainer
    @unlying that's easy
    Export Gideros project as Android project, install plugin into exported project, delete assets folder, which is inside assets folder in exported project, and you have yourself Gideros player for Android with FB plugin.

    I assume there are same steps for IOS player :)
  • I'm using your sample app and i'm having these errors:
    "GFacebook cannot be resolved FacebookActivity.java"
    and
    "Jar mismatch! Fix your dependencies"
    Something goes wrong for me.

    And any way to use it on PC?
  • ar2rsawseenar2rsawseen Maintainer
    @unlying unfortunately it can't be used on PC player. It's an Android plugin.
    So only if you can launch android apk on PC, like using BlueStacks or something, but that is usually not so handy.

    And about your problem, it looks like something similar to this:
    http://stackoverflow.com/questions/14515626/jar-mismatch-fix-your-dependencies-for-the-facebooksdk

    usually a problem in Android support library.


  • EmanuelEmanuel Member
    Hello

    I did everything as described, but when I run the app it closes test alone ... what can be the problem?

    Result emulator logcat:

    05-03 19:07:57.186: W/dalvikvm(1837): JNI WARNING: JNI method called with exception pending
    05-03 19:07:57.186: W/dalvikvm(1837): in Lcom/giderosmobile/android/player/GiderosApplication;.nativeDrawFrame:()V (GetStaticMethodID)
    05-03 19:07:57.186: W/dalvikvm(1837): Pending exception is:
    05-03 19:07:57.186: I/dalvikvm(1837): java.lang.NullPointerException:
    05-03 19:07:57.186: I/dalvikvm(1837): at com.giderosmobile.android.plugins.facebook.GFacebook.getFBToken(GFacebook.java:148)
    05-03 19:07:57.186: I/dalvikvm(1837): at com.giderosmobile.android.plugins.facebook.GFacebook.setAppId(GFacebook.java:57)
    05-03 19:07:57.186: I/dalvikvm(1837): at com.giderosmobile.android.player.GiderosApplication.nativeDrawFrame(Native Method)
    05-03 19:07:57.186: I/dalvikvm(1837): at com.giderosmobile.android.player.GiderosApplication.onDrawFrame(GiderosApplication.java:460)
    05-03 19:07:57.186: I/dalvikvm(1837): at com.giderosmobile.android.GiderosRenderer.onDrawFrame(FacebookTestActivity.java:220)
    05-03 19:07:57.186: I/dalvikvm(1837): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
    05-03 19:07:57.186: I/dalvikvm(1837): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
    05-03 19:07:57.186: I/dalvikvm(1837): "GLThread 99" prio=5 tid=11 NATIVE
    05-03 19:07:57.186: I/dalvikvm(1837): | group="main" sCount=0 dsCount=0 obj=0x40cefd78 self=0x2a1aa890
    05-03 19:07:57.186: I/dalvikvm(1837): | sysTid=1851 nice=0 sched=0/0 cgrp=apps handle=705983240
    05-03 19:07:57.194: I/dalvikvm(1837): | state=R schedstat=( 1554928830 3867307252 625 ) utm=136 stm=19 core=0
    05-03 19:07:57.214: I/dalvikvm(1837): #00 pc 000012a0 /system/lib/libcorkscrew.so (unwind_backtrace_thread+27)
    05-03 19:07:57.214: I/dalvikvm(1837): #01 pc 0005faa8 /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+35)
    05-03 19:07:57.214: I/dalvikvm(1837): #02 pc 00053914 /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+303)
    05-03 19:07:57.214: I/dalvikvm(1837): #03 pc 000539ae /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
    05-03 19:07:57.214: I/dalvikvm(1837): #04 pc 00038aba /system/lib/libdvm.so
    05-03 19:07:57.214: I/dalvikvm(1837): #05 pc 0003df2e /system/lib/libdvm.so
    05-03 19:07:57.214: I/dalvikvm(1837): #06 pc 000095e4 /data/app-lib/com.flipfloplab.facebooktest-2/libfacebook.so (gfacebook_authorize+284)
    05-03 19:07:57.214: I/dalvikvm(1837): #07 pc 0000801c /data/app-lib/com.flipfloplab.facebooktest-2/libfacebook.so
    05-03 19:07:57.214: I/dalvikvm(1837): #08 pc 0011776c /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #09 pc 00116aac /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #10 pc 001171ba /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #11 pc 00118376 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so (lua_call+13)
    05-03 19:07:57.224: I/dalvikvm(1837): #12 pc 00144b3a /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #13 pc 0011776c /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #14 pc 00117190 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #15 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #16 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #17 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #18 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #19 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #20 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #21 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #22 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #23 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #24 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #25 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #26 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #27 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #28 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #29 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.224: I/dalvikvm(1837): #30 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.234: I/dalvikvm(1837): #31 pc 00112ea8 /data/app-lib/com.flipfloplab.facebooktest-2/libgideros.so
    05-03 19:07:57.234: I/dalvikvm(1837): at com.giderosmobile.android.player.GiderosApplication.nativeDrawFrame(Native Method)
    05-03 19:07:57.234: I/dalvikvm(1837): at com.giderosmobile.android.player.GiderosApplication.onDrawFrame(GiderosApplication.java:460)
    05-03 19:07:57.234: I/dalvikvm(1837): at com.giderosmobile.android.GiderosRenderer.onDrawFrame(FacebookTestActivity.java:220)
    05-03 19:07:57.234: I/dalvikvm(1837): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
    05-03 19:07:57.234: I/dalvikvm(1837): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
    05-03 19:07:57.234: E/dalvikvm(1837): VM aborting
    05-03 19:07:57.234: A/libc(1837): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 1851 (Thread-99)

    thanks
    Emanuel
  • ar2rsawseenar2rsawseen Maintainer
    Hmm, thats strange the line NullPointer exception is pointing to is a quite harmless line:
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(sActivity.get());
    So unless there is a reason I'm not aware of, where shared preferences are not available, I can't really think of a reason.
    What device are you trying it on? Model, OS version, etc
  • EmanuelEmanuel Member
    I tested on two ... galaxy s3 4.1.2 and 4.2.2 emulator
  • EmanuelEmanuel Member
    the same problem in both
  • ar2rsawseenar2rsawseen Maintainer
    Hmm, can't really reproduce.

    If you comment out the line 57:
    String token = getFBToken();
    in src/com/giderosmobile/android/plugins/facebook/GFacebook.java

    and replace it with this line:
    String token = "";
    Do you have any other problems then?
  • EmanuelEmanuel Member
    now opens and close after....

    txt
    txt
    log.txt
    10K
    log.txt 10.2K
  • ar2rsawseenar2rsawseen Maintainer
    @Emanuel, can you send me your Android project? Like attach here on the forum or send by email to ar2rsawseen at gmail dot com
    Just so I could check that everything is set up normally? :)
  • EmanuelEmanuel Member
    Please tell me what you changed ... ok thank you
    zip
    zip
    FacebookTest.zip
    3M
  • @Emanuel is my friend...tks for help @ar2rsawseen you awesome
  • ar2rsawseenar2rsawseen Maintainer
    Hello @Emanuel ;)

    I've tried your project, but it does not have facebook plugin installed at all.

    You need to copy .so files, copy .java files and modify main activity like it's told here:
    https://github.com/ar2rsawseen/GiderosFacebookAndroidPlugin
  • EmanuelEmanuel Member
    Sorry, I sent the wrong file ....
    zip
    zip
    FacebookTest.zip
    7M
  • EmanuelEmanuel Member
    This is all done and the problem that I reported ...
  • ar2rsawseenar2rsawseen Maintainer
    @Emanuel it seems that you forgot to add GFacebook class to external classes in main Activity like this:
    static private String[] externalClasses = {
    	"com.giderosmobile.android.plugins.googlebilling.GGoogleBilling",
    	"com.giderosmobile.android.plugins.facebook.GFacebook",
    };
    You should of course also modify the GFacebook class back as it was ;)
  • EmanuelEmanuel Member
    Thank you. worked!!
Sign In or Register to comment.