Facebook Share dialog causing FATAL EXCEPTION, Android Enterprise

Hi,

I’m in the process of updating a few apps to be compliant with the Facebook v4 plugin. On iOS, this process was fairly straightforward. However, on Android, it seems to copletely break the app request dialogue. Whenever I run it, the app crashes with:

W/System.err(15690): java.lang.NoSuchMethodError: No virtual method setSuggestions(Ljava/util/List;)Lcom/facebook/share/model/GameRequestContent$Builder; in class Lcom/facebook/share/model/GameRequestContent$Builder; or its super classes (declaration of 'com.facebook.share.model.GameRequestContent$Builder' appears in /data/app/com.X.X-1/base.apk) W/System.err(15690): at plugin.facebook.v4.FacebookController$8.run(FacebookController.java:1217) W/System.err(15690): at android.os.Handler.handleCallback(Handler.java:739) W/System.err(15690): at android.os.Handler.dispatchMessage(Handler.java:95) W/System.err(15690): at android.os.Looper.loop(Looper.java:145) W/System.err(15690): at android.app.ActivityThread.main(ActivityThread.java:5832) W/System.err(15690): at java.lang.reflect.Method.invoke(Native Method) W/System.err(15690): at java.lang.reflect.Method.invoke(Method.java:372) W/System.err(15690): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) W/System.err(15690): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) W/FlurryAgent(15690): Error logged: uncaught E/AndroidRuntime(15690): FATAL EXCEPTION: main

The other dialogues seems to work. Also note that I am using the code from the provided example for testing this:

facebook.showDialog( "requests", { message = "You should download this game!", filter = "APP\_NON\_USERS" })

It seems like the “setSuggestions” function is missing; which is weird in the first place since I’ve tried it both with and without sugestions.

I am using all the latest builds for enterprise and the plugins for the record. 

Has anyone run into this problem as well? 

Thanks.

We are tracking through some Facebook bugs now. Can you put together a test app that has this problem and submit a bug report please? It needs to be a complete project that our engineer can run and not have to guess at settings, files etc. Put all of it in a zip file and use the Report a Bug link at the top of this page.

Thanks

Rob

I have the same problem, is there any news?

How are you guys hooking in the Facebook SDK, through the source code provided with Corona Enterprise, or the compiled JAR file? If you’re using the distributed source code, you might try using the compiled JAR file of the Facebook SDK instead.

First of all I tried to follow the Enterprise Facebook instructions precisely, but 

android.library.reference.2=${CoronaEnterpriseDir}/Plugins/sdk-facebook/android/4.5.0/facebook 

is not picked up from my project’s gradle.properties for some reason, and I had a crash on app start with missing com.facebook classes.

Then I tried adding

compile 'com.facebook.android:facebook-android-sdk:4.5.0' 

to my build.gradle dependencies, and app starts correctly but there is this error we talk about when launching “requests” dialog.

I also tried to comment that dependency and use facebook_sdk.jar from the enterprise plugin, but then I had another error about R.layout when running the dialog

This method is weird, in the source code it has a concrete java class as a parameter - ArrayList<String>, which is usually a very bad practice. Maybe Facebook devs had a specific reason to put it there, I don’t know, but the preferred way is to have interface like List<String>.

Anyway, somehow in the compiled version of the class GameRequestContent from “facebook_sdk.jar” (Corona enterprise plugins) method is different and uses List<String>! Also in later versions of Facebook SDK, i.e. 4.14, they only ship compiled classes and this one too has a List<String> as a parameter type. I haven’t tried these late SDKs as they enforce a minimumSdk for android to be 15, and we have 10 and don’t want to up this setting.

So I think error comes when reflexion invokes the method, it looks for the one with List<String>, but compiled version from sources has ArrayList<String> parameter and it is technically a different method.

I noticed that they changed the parameter type of that method in later versions of the Facebook SDK as well.

You might also try using the forked Facebook SDK we have on GitHub: https://github.com/coronalabs/plugins-sdk-facebook-android.

This is still in an experimental phase, but it does still support API Level 10, and is currently at version 4.13.1 I believe.

Thank you, setting up Facebook module from this code worked for me!

But isn’t it easier to update facebook.v4 source code with fix for setSuggestions method call, so it would work with 4.5.0 Facebook dependency out of the box?

Any update? Using an experimental version does not seem optimal and I cannot find a plugin.facebook.v4.jar file in it. Unfortunately have no opportunity to build it in my current workflow :frowning:

I don’t know of any reason why you can’t continue to use the legacy Facebook plugin for now. It targets API 2.1 which is the current minimum and should be that way until next August.

Rob

Official facebook docs say that 2.1 will become deprecated starting October 30, 2016

Deprecating doesn’t mean getting rid of now, it usually means getting rid of in the future, here’s your warning. Can you link me to that page?  2.0 has been deprecated for some time and FB got rid of it earlier this month.

Rob

Here it is: https://developers.facebook.com/docs/apps/changelog

They say in the docs, when you click on the value in “Available Until” column:

Version Schedules

Each version is guaranteed to operate for at least two years.  A version will no longer be usable two years after the date that the subsequent version is released.

Version 2.2 was introduced 30 October 2014, so 2.1 will be unavailable starting from 30 October 2016.

As I understood it doesn’t mean it would surely break, but all 2.1 calls will be directed to 2.2 handler mechanism starting from that date.

That’s what happened with 2.0, they were redirected to 2.1

We are tracking through some Facebook bugs now. Can you put together a test app that has this problem and submit a bug report please? It needs to be a complete project that our engineer can run and not have to guess at settings, files etc. Put all of it in a zip file and use the Report a Bug link at the top of this page.

Thanks

Rob

Hey everyone,

 

The Facebook-v4 (now known as simply “Facebook”) plugin is now out of beta:

https://coronalabs.com/blog/2016/10/28/facebook-plugin-update-we-are-out-of-beta/

 

And with that, we’ve revised how to integrate the Facebook plugin into an Android Corona Enterprise project.

 

The previously mentioned Github repository is now the primary method to get Corona’s modified Facebook SDK on Android.

 

We hope that the overhauled procedure is easier to get along with and helps resolve any possible SDK version conflicts:

https://docs.coronalabs.com/plugin/facebook-v4/index.html#android-1

 

Similarly, we’ve added a new Facebook Versioning/Upgrade guide that will hopefully help address other compatibility concerns:

https://docs.coronalabs.com/plugin/facebook-v4/fbUpgrade.html

I have the same problem, is there any news?

How are you guys hooking in the Facebook SDK, through the source code provided with Corona Enterprise, or the compiled JAR file? If you’re using the distributed source code, you might try using the compiled JAR file of the Facebook SDK instead.

First of all I tried to follow the Enterprise Facebook instructions precisely, but 

android.library.reference.2=${CoronaEnterpriseDir}/Plugins/sdk-facebook/android/4.5.0/facebook&nbsp;

is not picked up from my project’s gradle.properties for some reason, and I had a crash on app start with missing com.facebook classes.

Then I tried adding

compile 'com.facebook.android:facebook-android-sdk:4.5.0'&nbsp;

to my build.gradle dependencies, and app starts correctly but there is this error we talk about when launching “requests” dialog.

I also tried to comment that dependency and use facebook_sdk.jar from the enterprise plugin, but then I had another error about R.layout when running the dialog

This method is weird, in the source code it has a concrete java class as a parameter - ArrayList<String>, which is usually a very bad practice. Maybe Facebook devs had a specific reason to put it there, I don’t know, but the preferred way is to have interface like List<String>.

Anyway, somehow in the compiled version of the class GameRequestContent from “facebook_sdk.jar” (Corona enterprise plugins) method is different and uses List<String>! Also in later versions of Facebook SDK, i.e. 4.14, they only ship compiled classes and this one too has a List<String> as a parameter type. I haven’t tried these late SDKs as they enforce a minimumSdk for android to be 15, and we have 10 and don’t want to up this setting.

So I think error comes when reflexion invokes the method, it looks for the one with List<String>, but compiled version from sources has ArrayList<String> parameter and it is technically a different method.