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

Facebook Android Plugin

135

Comments

  • Ahh... I thought I ws going crazy for a couple of hours last night. I should have just tried it without the line active. lol.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • @ar2rsawseen sussed it all out... the Graph API Explorer is excellent to play with.

    i found the API Explorer and code snippets in the forums, so it now posts direct from the game with only a user login to facebook if it needs it. it also listens for completed posts and awards a star. :)

    i only set the ID if the user chooses to post on facebook, so the first time i check and set it once. The first time never used to post, until i put a delay of around 30sec, now its all good.

    Thank you again.

    Called when the button is clicked.
    i put a picture and variables for the level and score, looks good on facebook.
    function EndLevel:postFacebook()
     
    	if facebookSet == false 
    	then
    		facebook:setAppId("myAPPID99999");
    		facebook:authorize({"publish_actions"});
    		facebookSet = true
    	end
     
    	Timer.delayedCall(40000, 
    		function()
    			if facebook:isSessionValid() 
    			then
     
    				facebook:graphRequest("me/feed", {
    					link = "<a href="https://play.google.com/store/apps/details?blah"" rel="nofollow">https://play.google.com/store/apps/details?blah"</a>, 
    					picture = "<a href="http://app6.websitetonight.com/projects2/blah.png"" rel="nofollow">http://app6.websitetonight.com/projects2/blah.png"</a>, 
    					name = "My Game", 
    					caption = "My Game is good Fun", 
    					message = "Can you beat my Level "..gameLevel.." score, of "..levelScore.."! Download this fun game to your Android Mobile now."
    				},"POST")
    			end
    		end
    	)
     
    end

    The Listener started in the End Level class.
    		facebook:addEventListener(Event.REQUEST_COMPLETE, function(e)
    			stars.earnt  = stars.earnt + 1
    			stars.current = stars.current + 1
    			dataSaver.saveValue("stars", stars)
    		end)
    I tried to trap errors, and allow the user to retry... but it dont seem to catch it, for example when i unplug the internet, its not called. but it just flashes up a page not found and carries on... so not too fussed.
     
    		facebook:addEventListener(Event.REQUEST_ERROR, function(e)
     
    			local alertDialog = AlertDialog.new("Post Facebook", "Facebook post failed.  Try Post Again ?", "Cancel", "Yes", "No")
     
    			local function onComplete(event)
    				if event.buttonIndex == 1 
    				then
    					-- Try Post Again
    					EndLevel:postFacebook()
    				end
    			end
     
    			alertDialog:addEventListener(Event.COMPLETE, onComplete)
    			alertDialog:show()
    		end)
    	end

    @-) i think ill leave the facebook stuff for abit and carry on with other bits :)
  • amaximovamaximov Member
    edited September 2013
    Just encountered a bug. I tried integrating the plugin both via Android Studio and Eclipse method with the same results. As soon as I try to call facebook:extendAccessToken() I get a Java crash. Attached is the log. The exact same Lua code works flawlessly on iPhone so it must be something with the Android plugin?

    Note:Using Facebook Android SDK v 3.5 Should I downgrade to an older version? Eclipse is showing a lot of the methods like fb.whateverMethod in GFacebook.java to be depreciated.
    txt
    txt
    log.txt
    4K
  • @ar2rsawseen I just "downgraded" to the sdk you posted in your first post and extendAccessToken still crashes. Other methods seem to work normally for now.
  • I see, your log helped greatly, let me fix it now ;)
  • I have updated it both in Github repo and Gideros Labs, all you need to replace is the GFacebook.java in your project's src/giderosmobile/android/plugins/facebook folder ;)
  • amaximovamaximov Member
    edited September 2013
  • @ar2rsawseen is this possible to build apk file of gideros player that support "Facebook Android Plugin"? So that we can test quickly on device? If yes would you please take some notes and i will try to implement! Thank you so much!
    Coming soon
  • is there any similar plugin for twitter which works for both ios and android? i know there is one for ios but what about android

    :)
  • @vitalitymobile sure, you just export any Gideros project to Android, add Facebook Plugin to it, then delete its assets folder inside assets folder and you have yourself a Gideros player with preinstalled Facebook plugin:
    http://docs.giderosmobile.com/deployment.html (Device player with plugins)

    @hgvyas123 Unfortunately there is no official Twitter SDK, so no guarantee one would exist for Android with the same functionality as in ios.

    But there are also third party services, like https://www.addthis.com or http://www.sharethis.com which might provide similar functionalities to multiple social networks.
    +1 -1 (+2 / -0 )Share on Facebook
  • so in that case i would like to go with web trick

    :)
  • If you are looking for just the iOS solution then using bhWax with the iOS twitter or the Social sharing API, it is just a couple of lines and easy to use. Androids, however are not that easy.

    An article written long ago, nearly last year...
    http://howto.oz-apps.com/2012/09/tweet-tweet-right-from-your-lua-app.html

    Likes: thanhquan1512

    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
    +1 -1 (+1 / -0 )Share on Facebook
  • @ozapps :-

    yup i had read that article already but as you thought i need this for android also

    :)
  • I don't know why, but copy all files to workspace made me encounter “Conversion to Dalvik format failed with error 1”
    Tried many things, but failed.

    So what i do is put FacebookSDK folder outside the project folder,
    import them without copying, and then add this to project.properties:
    android.library.reference.1=../FacebookSDK
  • Don't know if that makes a difference, but I do not directly add it to properties, but rather, right click on the project, properties -> Android -> Library section, click add and add the FacebookSDK library from the list

    and seems to be working fine for me :)
  • @ar2sawseen :
    Yeah, i also wonder what is wrong with mine. Doing roperties -> Android -> Library section is the same with adding that. But sometime it will written as drive path, which made an error. So i need to change it that to ../Facebook.

    Oh yeah. That Dalvik format error only appear when i try to export as apk.
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2013
    if Library section adds drive path, it means that project folder and SDK folder are not in same workspace/folder and thats maybe what causing the problem
  • Hmm.. When that drive path appears, it would give another error, not that Dalvik Error 1.
    I'm not sure since searching about Dalvik Error 1, would return so much possibility of reason. But at least, not doing copy things work for me (also save time when Gideros exporting App, i just need to clean to update the project).
  • Ugh now I'm getting this issue "Dalvik Error 1" in Eclipse. Started randomly with a previously working project. I even re-exported and setup Facebook plugin again and I'm still getting this error. No clue how to fix it.

    Here is a screenshot of my project:

    Note: Those strange dependencies were added automatically when I linked my project to use HeyZap and Facebook libraries.
    Capture.PNG
    468 x 439 - 27K
  • amaximovamaximov Member
    edited November 2013
    UPDATE: @ar2rsawseen you should include this in FAQ or Troubleshooting. Unchecking "Build automatically" under "Project" menu in Eclipse fixed the issue for me. Such a wierd fix...
  • Another issue has come up. I'me making a custom Gideros player for a single project with HeyZap plugin, Notification, and Facebook plugin for Android. I've done plugin setups for Gideros plenty so I'm sure I set up the basics correctly. My issue is that my app works fine until I call require"facebook" at which it crashes with a strange printout before dying.

    Attached is the ADB log. All the plugins work fine except for the Facebook one which just crashed mysteriously whenever I try to require it from Lua
    txt
    txt
    log.txt
    8K
  • @amaximov the only thing that comes to mind, is that you are using new Gideros version, but old plugin libfacebook.so file.

    You need to go to Gideros installation folder and replace it with new libfacebook.so files from there
  • Yay that did it! Just wondering, does your GitHub repo always host the latest version of the plugin?
  • @amaximov I think not since the plugin have been bundled with the Gideros :)
  • I'm getting a crash similar to one that was reported earlier. I've taken a brand new Gideros project and written a very small app based on the sample app that came with the Facebook plugin. As soon as I enable the following line:

    facebook:setAppId("myIdHere");

    the app crashes when I try to debug it in Eclipse. Here's the last line from logcat:

    12-11 03:33:22.534: A/libc(4978): Fatal signal 11 (SIGSEGV) at 0x00000020 (code=1), thread 4991 (Thread-173)

    I've attached the full log in case that helps.

    I tried putting some Log.w() statements in GFacebook.java to try to figure out where the crash was occurring and as soon as I did that for some reason the debugger started pausing at the following line, even though I didn't set any breakpoint:

    static public void init(long data)
    {
    Log.w("FacebookTest", "in GFacebook.init(" + data + ")");
    ===> sData = data;
    }

    If I step over that line, the Fatal signal 11 occurs when I step over the closing brace.

    I've checked and double-checked and I have the .so files in place, FacebookSDK is added as a library, and I've added the two lines of code that are indicated in the instructions (I also tried with and without the 3rd line that's mentioned in the instructions since later comments said it is no longer necessary).

    I've attached the lua code as well in case that helps. If you want the entire Eclipse project, let me know. I swear I've got everything the way the instructions said... I had an earlier project working with it but then something went haywire and I tried to recreate the project from scratch and haven't been able to get the Facebook plugin working since. I even tried removing the FacebookSDK from my workspace and readding it, to no effect (other than the fact that my test project started complaining about not finding the facebook SDK files so I had to add the project to the Projects folder in the build path to get that to go away).

    I've tested this out on a Genymotion vm as well as on my HTC One and get the exact same result. Right now I'm at a loss so I'm hoping the logcat error will mean something to you and you can let me know what's wrong.

    "Help me, @ar2rsawseen, you're my only hope!" :-)
    txt
    txt
    facebook_crash_log.txt
    5K
    lua
    lua
    main.lua
    2K
  • @krl3000 sure
    firstly if you use latest Gideros version (2013.09.1), you should use the .so files provided with the Gideros (inside Gideros installation folder/ All Plugins/ Facebook, etc)

    and if you are using latest Gideros version and those .so files and it sill crashes, send me your exported Android project with your set up plugin and I will try to check it out ;)
  • Aaaah, I didn't realize that there were new provided so files in the latest version. I'm sure that's the problem. I'll try that today after work and let you know. Thanks!
  • Yep, that did it. Thank you very much! One more question: I noticed that there are several plugins whose names have changed (liblsqlite3 to lsqlite3, libjson to json, libbitop to bitop, liblfs to lfs, and libluasocket to luasocket). Should I delete the "lib*" versions in my project and replace them with the new ones as well?
Sign In or Register to comment.