Cannot compile Android App - Problem with autogenerated Implementor classes

atomarasatomaras Anargyros TomarasUSMember
edited April 2013 in Android

Hi,

I managed to generate a binding library for my Android java library.

When i reference it though within my clean Android App i cannot get the App to compile.

The errors i am getting are because of the autogenerated (by Xamarin) XXXImplementor classes.

For example in some cases where my java code defined listener interfaces i.e

public interface MyListener {}

The output binding dll contains two extra classes called MyListenerInvoker and MyListenerImplementor.

When compiling the Android App that references that dll though this is the error i am getting:

C:\Users\Anargyros\Documents\Projects\TestAndroidBinding\AndroidApp\obj\Debug\android\src\mono\com\path\to\listener\MyListenerImplementor.java(38,38): Error:  package com.path.to.listener does not exist
    com.path.to.listener.MyListener

Any ideas how can i workaround this problem?

Thank you.

Posts

  • atomarasatomaras Anargyros Tomaras USMember

    I am attaching 2 screenshots that highlight the issue

    AndroidError.JPG
    774 x 263 - 43K
    AndroidError2.JPG
    868 x 248 - 47K
  • JonathanPryorJonathanPryor Jonathan Pryor USModerator, Xamarin Team Xamurai

    The problem is that the .jar that contains com.*.android.io.HorizontalPager.OnScreenSwitchListener isn't present on the javac command line, so javac reports compilation errors when compiling the Android Callable Wrappers.

    Please change the Build action of your .jar in your Binding project to EmbeddedJar. This will add the .jar to the javac command line, allowing the Android Callable Wrappers to compile.

  • atomarasatomaras Anargyros Tomaras USMember
    edited April 2013

    Awesomeness!! It worked.

  • JonathanPryorJonathanPryor Jonathan Pryor USModerator, Xamarin Team Xamurai
    java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ShareCompat$ShareCompatImplJB;
    

    You've added android-support-v4.jar to your project twice. Remove one of the references.

    Note: Mono.Android.Support.v*.dll embeds android-support-v*.jar, so if you reference any of the support libraries you'll already get a set of those types.

  • atomarasatomaras Anargyros Tomaras USMember

    Now that i try to run the Android App i get this error :

    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(3,3): Error MSB4018: The "BuildApk" task failed unexpectedly.

    System.ArgumentException: An item with the same key has already been added.

    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)

    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)

    at Ionic.Zip.ZipFile._InternalAddEntry(ZipEntry ze)

    at Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive)

    at Xamarin.Android.Tasks.BuildApk.AddNativeLibrary(ZipFile apk, String path, String abi)

    at Xamarin.Android.Tasks.BuildApk.AddNativeLibraries(ZipFile apk)

    at Xamarin.Android.Tasks.BuildApk.Execute()

    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

    at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() (MSB4018) (AndroidApp)

  • atomarasatomaras Anargyros Tomaras USMember

    It seems this is because i have also included the native libs twice.Once in the binding project and once in the App project.

Sign In or Register to comment.