Machinarius
Machinarius

Reputation: 3731

Xamarin java binding ignores support jar

I need to use http://viewpagerindicator.com/ to add static tabs below the actionbar on a Xamarin.Android project.

I downloaded the project and migrated it from maven to gradle to build it into an AAR file suitable for Xamarin consumption. I created a java binding project, added the AAR file as a LibraryProjectZip and added the v13 support jar as a ReferenceJar but it seems it is being lost somewhere in the way as evidenced by these xbuild logs:

BINDINGSGENERATOR:  warning BG8C00: For type Com.Viewpagerindicator.IPageIndicator, base interface android.support.v4.view.ViewPager.OnPageChangeListener does not exist.
BINDINGSGENERATOR:  warning BG8800: Unknown parameter type android.support.v4.view.ViewPager.OnPageChangeListener in method SetOnPageChangeListener in managed type Com.Viewpagerindicator.IPageIndicator
BINDINGSGENERATOR:  warning BG8800: Unknown parameter type android.support.v4.view.ViewPager in method SetViewPager in managed type Com.Viewpagerindicator.IPageIndicator

The warnings chain continues for a long time, ending the process with a severely limited port as the missing types make the methods depending on them to vanish away.

If i remove the support jar, the build fails because of missing classes from a utility named jar2xml, leading me to believe it is only used for part of the compilation/mapping process.

The support jar was taken from an unmodified android sdk at extras/android/support/v13/android-support-v13.jar.

Any help is most welcome.

Upvotes: 2

Views: 814

Answers (1)

Alex Sorokoletov
Alex Sorokoletov

Reputation: 3101

There is a workaround to make these things work.

In my example, I had 2 reference jars (android-support-v4.jar and google-play-services.jar). So if you just add these 2 jars with Build Action = ReferenceJar, you will see same errors as you posted.

BINDINGSGENERATOR:  warning BG8800: Unknown parameter type com.google.android.gms.maps.model.Marker in managed type Com.Google.Maps.Android.MarkerManager.

Though the Marker and MarkerManager classes are defined in the jars, they're not getting resolved correctly on the C# side. To fix that you need to do is to just add already compiled C# bindings for these jars as references.

In my case I used Xamarin.GooglePlayServices package which had a dependency Xamarin.Android.Support.v4 (exactly as my jars).

In your case, you just need to add Xamarin.Android.Support.v4 package to your binding project.

In the end you will have something like this in your project structure:

Sample structure for Bindings project with same problem

Hope that helps!

Upvotes: 2

Related Questions