Pyjnius, Facebook/Google SDK for Sign in Button with Kivy

249 views
Skip to first unread message

Guga Figueiredo

unread,
Sep 20, 2016, 4:14:43 PM9/20/16
to Kivy users support
So I have been wondering. Can this be implemented with kivy?

I have seen read this post in kivy planet about it, but noticed that the login button was a problem.
But the article is from 2013. So I would like to know what is the current situation regarding Facebook and Google SDKs.

First of all, i'd like to know how to install them without android-studio, if possible.
Then, how to propperly integrate them with my app.

Hope someone can shed some light in the matter

Tom

unread,
Sep 22, 2016, 3:09:05 PM9/22/16
to Kivy users support
Hi Guga,

Good to know I'm not alone in trying to figure this out.

I've been attempting this over the past few days, and I'm struggling with getting the facebook SDK to be referenced correctly. When I reference using autoclass with pyjnius it cannot find the correct libraries. Attempted with both new and old Facebook SDK's. Could anyone enlighten me on the correct way to reference the android.library.reference in the buildozer.spec file? Also attempted to alter the project.properties file with the correct path to the library but I always get a compilation error when I try this.

Some help would be great. Really close to getting an app ready and I'm losing my mind on this!

Guga Figueiredo

unread,
Sep 22, 2016, 4:04:27 PM9/22/16
to Kivy users support
Hey budtom7,

Glad someone joined in the conversation.

Yesterdeay I was able to build without errors the application from the example at kivy planet. It didn't run on my phone, but I installed straight from apk instead of adb. Trying this out today. This was done following the instructions offered on the site, which means no buildozer, only p4a. Don't know what changes between them. Here are the changes on the steps from the tutorial on the website I had to make:

 On "Setup our application" part of the example:

steps 3 through 6 are overwritten by this in the new toolchain of p4a:
$ p4a apk --private $HOME/path/to/p4a-facebook-example/src  --package=org.example.myapp --name "My application" --version 0.1 --bootstrap=sdl2 --requirements=python2,kivy


this generates all the necessary files
$HOME/.local/share/python-for-android/dists/your_dist/

From there just follow the example. 

Can you specify the errors you are experiencing?
Over here it built without errors, only some warnings about missing headers. I was able to transfer the APK to my phone and install it without trouble. But it failed to run. I wonder if maybe API Number was at fault. I built for target 14 API, my phone is 22. I will try both installing through adb for debbug and upping the target API.

Tom

unread,
Sep 22, 2016, 4:46:29 PM9/22/16
to Kivy users support
Can't say I've used p4a directly before, only ever used buildozer and I'm a novice at that really. So i'm not going to be much help there I'm afraid.

The error I'm getting is when I try to use pyjnius to call a class ie. Session = autoclass('com.facebook.Session'), I get jnius.jnius.JavaException: Class not found 'com/facebook/Session'. I believe the root of this problem is that during building of my apk the sdk libraries are not being referenced correctly? I'm new to using SDKs such as facebook so sorry if this makes little sense. 

I did a little research online and attempted to add the reference correctly in the buildozer.spec file, or alternatively as kivy planet mentions adding it to the project.properties file manually (which is what adding it to the buildozer.spec file does automatically I think).

Not sure if this will be of use to you https://github.com/samjhyip/Simple-Facebook-Login-on-Kivy


I'm a bit lost to be honest, using a jar file as indicated in this SDK integration seems like a simple solution, https://github.com/kivy/kivy/wiki/AdBuddiz-Android-advertisements-integration-for-Kivy-apps, but I'm not sure how easy is it to make a jar file from the facebook sdk (or if you even should?).

Tom
Reply all
Reply to author
Forward
0 new messages