Bug 9348 - Binding fails with latest (even semi-modern) version of the Facebook SDK
Summary: Binding fails with latest (even semi-modern) version of the Facebook SDK
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 4.4.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2013-01-07 17:30 UTC by Brett
Modified: 2013-03-05 14:58 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Brett 2013-01-07 17:30:40 UTC
Tested with the monodroid facebook sample (https://github.com/xamarin/monodroid-samples/tree/master/Facebook)

Build the latest Facebook SDK (https://github.com/facebook/facebook-android-sdk)
Add it to the monodroid facebook sample (replace com.android.facebook.zip with newly built SDK)
Try to build.

You will get build errors:
/Users/brett/code/monodroid-samples/Facebook/Mono.Facebook/obj/Debug/generated/src/Com.Facebook.Model.PropertyNameAttribute.cs(18,18): Error CS0234: The type or namespace name `Runtime' does not exist in the namespace `Com.Facebook.Android'. Are you missing an assembly reference? (CS0234) (Mono.Facebook)

Adding the Mono.Android.Support.v4 dll as a reference to the Mono.Facebook project causes different errors, specifically a name collision in generated code:

/Users/brett/code/monodroid-samples/Facebook/Mono.Facebook/obj/Debug/generated/src/Com.Facebook.Session.cs(39,39): Error CS0102: The type `Com.Facebook.Session.OpenRequest' already contains a definition for `id_setPermissions_Ljava_util_List_' (CS0102) (Mono.Facebook)


Furthermore, the monodroid facebook sample uses com.facebook.android which is a deprecated package.
Comment 1 Atsushi Eno 2013-01-08 08:59:10 UTC
I found that the latest Facebook SDK uses types from org.json and java.lang.reflect a lot and they are not supported in MfA, likely resulted in this problem. Needs to sort out what exactly causes it.
Comment 2 Adrian Pell 2013-01-16 01:18:59 UTC
That issue with Com.Facebook.Session.OpenRequest seems to occur because both OpenRequest and its parent class AuthorizationRequest define a method:

   setPermissions(List<String> permissions)

For some reason, when the Java Binding Library project is generating the stub classes, it puts both of those methods onto the Com.Facebook.Session.OpenRequest class ... and then adds that id_SetPermissions_Ljava_util_List_ static IntPtr as the handle for the native method. Hence, the redefinition since the signatures are the same.

There's no way around that with transforms, however, since the method is in the wrong class.  I did go back to the source in Eclipse and changed the base class method name there - which got round that problem.  However ...


The earlier error that Brett mentions still exists.  Again, it's look like a code generation problem, since the annotation in Com.Facebook.Model.PropertyNameAttribute looks like:

  [Android.Runtime.Annotation ("com.facebook.model.PropertyName")]

In this case, the Android name is resolved to the wrong namespace - Com.Facebook.Android (I think).  Manually making that global::Android.Runtime..... does let it compile, although you have to make that change in the generated code after every rebuild :-(

With all that, the Java Binding Library project compiles ...



Actually using the output in another project is something else again, however, which I haven't got to the bottom of yet.  I may have to back off to the (deprecated) sample project code for the time being.
Comment 6 Atsushi Eno 2013-02-07 11:25:53 UTC
I forgot to mention: annotation-mapped attributes will be prefixed "global::" in the next release, so the issue will be gone, Adrian.
Comment 7 Atsushi Eno 2013-03-05 14:58:08 UTC
This issue is fixed in the latest "xamarin 2.0" release. I updated monodroid-samples as well.