Bug 26737 - Project containing Xamarin.GooglePlayServices and Infragistics fails to build
Summary: Project containing Xamarin.GooglePlayServices and Infragistics fails to build
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.20.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jon Dick
URL:
Depends on:
Blocks:
 
Reported: 2015-02-04 12:02 UTC by Cody Beyer (MSFT)
Modified: 2015-02-10 21:55 UTC (History)
3 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 Cody Beyer (MSFT) 2015-02-04 12:02:00 UTC
### Description

When a project contains references to both Infragistics, and Xamarin.GooglePlaySerives, build will fail due to "too many method references"

### Test Case

https://www.dropbox.com/s/8yfuvaghqbkegpo/TestInfra.zip?dl=0

### Build Logs

Attached

### Steps to Reproduce

1. Open linked test case
2. Attempt to build

### Expected Results

App builds without error

### Actual Results

App builds with error similar to that demonstrated in the attached log

### Version

=== Xamarin Studio ===

Version 5.7.1 (build 14)
Installation UUID: 05ebd865-76e1-4bc2-84a5-7bba54e97af1
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: 8.6.1.20 (Business Edition)
Hash: 3b3ef43
Branch: 
Build date: 2015-01-24 09:42:21-0500

=== Xamarin.Mac ===

Version: 1.12.0.4 (Business Edition)

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Build Information ===

Release ID: 507010014
Git revision: a4dd61ad7f8b3695be4b17bcb5c3ae6b81438cf7
Build date: 2015-01-19 15:21:09-05
Xamarin addins: 081208fe3bbf40e24a562867c6c7fba20a9b94b6

=== Operating System ===

Mac OS X 10.10.2
Darwin beyer.router 14.1.0 Darwin Kernel Version 14.1.0
    Mon Dec 22 23:10:38 PST 2014
    root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64
Comment 1 Atin 2015-02-04 13:14:25 UTC
I have checked this issue with the help of given sample and able to reproduce this behaviour. When I build the given sample then the build stops with the following error.

Error:
trouble writing output: Too many method references

Build Output:https://gist.github.com/Arpit360/bfa1039a7919d94362ad
IDE Logs:https://gist.github.com/Arpit360/c61eaa48ae1f0d7d1e83

Environment Info:

=== Xamarin Studio ===

Version 5.7.1 (build 14)
Installation UUID: 3d25a767-a003-4a7d-9f5e-e57987cf6cf0
Runtime:
	Mono 3.12.0 ((detached/de2f33f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000076

=== Xamarin.Android ===

Version: 4.20.0.28 (Enterprise Edition)
Android SDK: /Users/mac360_xamarin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: 8.6.1.20 (Enterprise Edition)
Hash: 3b3ef43
Branch: 
Build date: 2015-01-24 09:42:21-0500

=== Xamarin.Mac ===

Version: 1.10.0.18 (Enterprise Edition)

=== Build Information ===

Release ID: 507010014
Git revision: a4dd61ad7f8b3695be4b17bcb5c3ae6b81438cf7
Build date: 2015-01-19 15:21:09-05
Xamarin addins: 081208fe3bbf40e24a562867c6c7fba20a9b94b6

=== Operating System ===

Mac OS X 10.10.0
Darwin mac360-xamarins-Mac-mini.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 gmurray 2015-02-10 18:37:18 UTC
For more information, this seems to be because adding both Infragistics' product and Google Play Services pushes the number of method references over the 65k method reference limitation in the dex file.

Possible solutions include:
* Implement a way to use MultiDex for Xamarin.Android: https://developer.android.com/tools/building/multidex.html
* If such a way already exists, then make it clearer how one should enable that mode, or if it is supposed to be automatic, then why didn't it enable here?
* Maybe modularize the google play services bindings? I think Google Play Services has a more modular breakdown that you can use now. This isn't really an end-game solution, though, as someone may want to reference all the google play services bits in one app.
* Infragistics (us) could also modularize our bindings to our native Java bits, but, again, that only helps if someone doesn't want to use everything in one app.

I was able to work around the issue by doing the following:
http://www.infragistics.com/community/blogs/graham/archive/2015/02/06/flexing-xamarin-android-s-build-to-work-around-android-s-65k-method-limitation.aspx

But seeing as how I had to override some Xamarin.Android targets and extend some Xamarin.Android MSBuild tasks, it sure would be nice to have a cleaner way to do it. Additionally, I have no idea if doing this is a good idea with Xamarin.Android :) It seems reasonably safe since, presumably, changing the Application type to a MultiDexApplication will cause the ancillary dex files to be loaded before Xamarin tries to touch them, but you guys would know better than me what kind of fires this might start.
Comment 3 Jonathan Pryor 2015-02-10 21:55:56 UTC
Multi-dex support will be present in Xamarin.Android 5.1, via a new $(AndroidEnableMultiDex) MSBuild property (which will also be present in the IDE's Project Options/Properties dialogs).

Fixed in monodroid/fd4b388c.

Redth: I believe Google Play Services has also been split up into smaller libs; perhaps our component should follow suit?