Facebook as an extension

I’m still trying to update the FB extension and prepared a branch just to illustrate the issue I’m stuck with.

Here is a dev branch in forked repo from original defold facebook-extension: https://github.com/MaratGilyazov/extension-facebook/tree/update_6.3.0/android

I did just few changes: https://github.com/MaratGilyazov/extension-facebook/commit/997d9e26908cfaef90cfc6baffa08b21683fcd68

  1. First of all - switched dependencies to a new 6.3.0 SDK (now there is only one dependency required). If keep just this chane - extension itself can be build without any issues.

  2. But in a real project I also need Admob, so I’ve also added a dependency for Admob just to illustrate the conflict - now it fails with the message, I’ve mentioned in previous messages:

Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from AndroidManifest.xml:24:18-86 is also present at AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).

Thats the main issue I can’t solve by my own :frowning:

  1. I see there is a dependency for android.support.v4.app.FragmentActivity - I believe as long as FB switched to AndroidX there should be no refs to “old” support libs.
    When I run “Migrate to AndroidX” command from Android Studio it changes this import directive to androidx.core.app.FragmentActivity + asks me to add gradle.properties file with lines mentioned above:

android.enableJetifier=true
android.useAndroidX=true

But when I try to build from such state, it fails with such error:


And anyway, this class seems to be not used here at all, so I’ve simply commented it out, but this thing is minor, as build fails on step (2).

Any ideas what I’m doing wrong and how to fix the issue?

BTW, if I use only dependency to Admob itself, without facebook, it builds normally (in my ironsource extension, for ex), so build fails only in combination of FB extension and other up-to-date plugins like Admob or Firebase

Don’t you just love how messy Android development can be sometimes :slight_smile:

Important to keep in mind is that we use Gradle only to resolve project dependencies. The android.useAndroidX=true setting will be ignored.

The problem as I see it is that Facebook 6.3.0 still uses android.support.v4.app:

https://mvnrepository.com/artifact/com.facebook.android/facebook-common/6.3.0

2 Likes

Also, I found an interesting discussion in FB rep (especially last 2 comments): https://github.com/facebook/facebook-android-sdk/pull/689

2 Likes

So actually they did not switch to AndroidX yet :sob:

I saw that this PR named “Update to AndroidX” was not merged, but also there was something said about “this will be supported internally” and at first I thought this commit covered what needed:

But obviously it just switches version of used support libs, and it’s not about mirgation to AndroidX.

Ok, I’ll be waiting for further updates in FB repo.
Thanks for checking and sorry for disturbing on Saturday :slight_smile:

1 Like

And this Jetifier tool seems to be used for such migration “manually” somehow, but I don’t think it’s a right way to even give it a try: https://developer.android.com/studio/command-line/jetifier

1 Like

We have updated the Facebook extension to use Facebook SDK 6.5.1 for Android and iOS:

This is the last release on the 6.x branch of SDKs and the last SDK release which uses the old version of Android Support libraries. AndroidX is included in versions starting from 7.0.0 of the Facebook SDK for Android.

NOTE: We will not yet make this update to AndroidX as we also need to modify the build system to use the jetifier tool to automatically upgrade extensions to use AndroidX.

2 Likes

This Facebook blog post states that the version of the SDK used by extension-facebook (9.0.1) will be ‘sunsetted’ on June 8, 2023 this year - not just deprecated but apparently will no longer be operational.

I wasn’t able to find any further announcements, but v11 will suffer the same fate in October, and v12 and v13 are already deprecated.

v12 introduces a minimum requirement of iOS 10.0 (previously 9.0), v13 requires iOS 11.0 and v15 requires v12.0

I’m tempted to try an upgrade (although if it was too challenging I wouldn’t be able to spend much time on it) - any thoughts on which version? Personally I’d likely go for 14.1.0 which is the latest before the v15 upgrade requiring iOS 12.0. The latest v12 (12.3.2) is tempting but is already halfway through its 2-year deprecation period.

I would suggest that we try with v14.1.0, especially now that we also have Cocoapod support which means that we can get rid of the iOS frameworks. For iOS add a Podfile in manifests/ios, something like this one:

platform :ios, '11.0'
pod 'FBSDKCoreKit', '14.1.0'
pod 'FBSDKLoginKit' '14.1.0'
pod 'FBSDKShareKit' '14.1.0'
1 Like

The podfile seems to be ignored. Before I investigate further, is Cocoapod support available on build.defold.com or only build-stage.defold.com? I’m not sure which branch maps onto which server.

Correct, the functionality isn’t available yet, as it arrived after the last beta period started. Sorry for the confusion!
We will have a new beta server on monday (or sooner if @britzl releases one)

2 Likes

Indeed. My apologies! I mixed up our releases and thought we had this included in the last release. I will start preparing extensions this week so that they are ready for testing next week. I’ll include the Facebook extension in this work.

3 Likes

I saw the post about problems with Swift. Shall I proceed with a traditional (non-cocoapods) Facebook SDK upgrade or might Swift be supported soon?

1 Like

Yes, I think that will have to be our approach to this update until we make the required changes on the extender server.

I have a Draft PR but need someone to give me the Facebook Client Token for the sample project, to allow me to test the API features that our game doesn’t use.

1 Like

Sorry about the delay here @AarrrBee ! I’ll provide it later today.

1 Like

Added to the GitHub ticket!

1 Like

Hi. how to require facebook module in code, since it is not native extension.
im getting error “attempt to index global ‘facebook’ (a nil value)”
Defold 1.4.6
facebook-extension 7.2.0
@britzl

Since the facebook extension is only supported on iOS/Android, you should write your code like so:

if facebook then
    Do stuff
end

Hi. so this extension is not available on defold editor build?

Correct. The extension integrates the Facebook SDK for Android and iOS. And when you run your game using Project-Build it runs a desktop version of your game, for which there is no Facebook SDK.

1 Like