Bug 30274 - Java Library is compiled twice when it shouldn't be.
Summary: Java Library is compiled twice when it shouldn't be.
Status: NEEDINFO
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.20.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2015-05-20 14:13 UTC by Jonathan Pryor
Modified: 2016-06-26 13:34 UTC (History)
3 users (show)

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


Attachments
Upgraded Project (36.00 KB, application/zip)
2015-05-21 07:50 UTC, dean.ellis
Details
A custom Java binding with the same problem (2.87 MB, application/octet-stream)
2016-06-26 13:34 UTC, Dimitar Dobrev
Details


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 for Bug 30274 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEEDINFO

Description Jonathan Pryor 2015-05-20 14:13:54 UTC
Eric Maupin ran into this.

Repro:

1. Download Attachment #9110 [details] (from Bug #24286).
2. Open within an IDE.
3. Within the IDE, Update Package References.
3.a: We want/need Xamarin.Forms 1.4.2 (current stable).
4. Build.

Expected results: It builds!

Actual results: Not so much:

>  java.lang.IllegalArgumentException: already added: Landroid/support/v4/graphics/drawable/DrawableCompat$HoneycombDrawableImpl; (TaskId:280)
>  	at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122) (TaskId:280)
>  	at com.android.dx.dex.file.DexFile.add(DexFile.java:161) (TaskId:280)
>  	at com.android.dx.command.dexer.Main.processClass(Main.java:732) (TaskId:280)
>  	at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) (TaskId:280)
>  	at com.android.dx.command.dexer.Main.access$300(Main.java:83) (TaskId:280)
>  	at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) (TaskId:280)
>  	at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) (TaskId:280)
>  	at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) (TaskId:280)
>  	at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) (TaskId:280)
>  	at com.android.dx.command.dexer.Main.processOne(Main.java:632) (TaskId:280)
>  	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510) (TaskId:280)
>  	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280) (TaskId:280)
>  	at com.android.dx.command.dexer.Main.run(Main.java:246) (TaskId:280)
>  	at com.android.dx.command.dexer.Main.main(Main.java:215) (TaskId:280)
>  	at com.android.dx.command.Main.main(Main.java:106) (TaskId:280)

The cause of the crash is that the library Android.Support.v13\20.0.0\content\support\v13\android-support-v13.jar  is provided *twice* to the JavaLibrariesToCompile Task.

Why is this happening?
Comment 2 dean.ellis 2015-05-21 04:57:22 UTC
Weird. I tried to replicate this. 

1) Opened the Example project with XS 
2) Upgraded Packages to Latest in the Android project
3) Upgraded Packages to latest in the PCL project 
      Step 3 failed with 
Could not install package 'Xamarin.Forms 1.4.2.6359'. You are trying to install this package into a project that targets 'portable-Profile78', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

4) Given 3, I manually referenced the newer Xamarin.Forms.Core/Xaml assemblies from the PCL.
5) Built.

It worked on 5.1.99.284

Also tried building using dbuild on latest master and that worked too
Comment 3 dean.ellis 2015-05-21 07:50:46 UTC
Created attachment 11277 [details]
Upgraded Project
Comment 4 dean.ellis 2015-05-21 07:53:30 UTC
Added a zip containing the Upgraded projects. I upgraded both Android and iOS to the latest stable Xamrin Forms. 

A few things I did have to do was 

a) Set the Android project to compile using Framework 5.0
b) Add Xamarin.Forms.Platform reference to both Android and iOS otherwise it would not compile (something about the Renders being missing).

Still unable to repo the build issue.
Comment 5 Dimitar Dobrev 2016-06-26 13:34:53 UTC
Created attachment 16495 [details]
A custom Java binding with the same problem

I have hit what I think is the same error. Open my attached project, generate the binding, add a reference to it in an app and start the app. You'll get this:

1>  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lnet/sqlcipher/AbstractCursor$SelfContentObserver;
1>  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lnet/sqlcipher/AbstractCursor;
1>  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lnet/sqlcipher/AbstractWindowedCursor;
1>  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lnet/sqlcipher/BuildConfig;
1>  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lnet/sqlcipher/BulkCursorNative;
1>  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lnet/sqlcipher/BulkCursorProxy;
1>  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lnet/sqlcipher/BulkCursorToCursorAdaptor;
1>  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lnet/sqlcipher/CrossProcessCursorWrapper;
1>  Uncaught translation error: java.lang.IllegalArgumentException: already added: Lnet/sqlcipher/Cursor;

It happens every time.
The reason is that the original AAR (which you can find in Jars/) contains two copies of the same JAR - one named "classes" at the root and one named "sqlcipher" in jni/. This AAR is valid because it works with Java so it has to work with Monodroid as well. The original can only be downloaded through Gradle ( https://discuss.zetetic.net/t/sqlcipher-for-android-release-android-n-support/1465 ) in case you want to get it yourselves.
I worked around the bug by unpacking the AAR, deleting the copy in jni/ and then packing it again. Still, it would be nice to have this fixed.