4

I am developing xamarin android app and in this many packages and references are used (Google play services). When I try to build this project I get this error:

java.exe exited with code 2 Trouble writing output: Too many field references: 81626; max is 65536. You may try using --multi-dex option

.

Wosi
  • 41,986
  • 17
  • 75
  • 82
Parth Savadiya
  • 1,203
  • 3
  • 18
  • 40

3 Answers3

1

You need to enable Mutlidex in your project. Xamarin.Android supports this since version 5.1:

Multi-dex support can be enabled by using the new $(AndroidEnableMultiDex) MSBuild property, which is also available via Visual Studio and Xamarin Studio.

Wosi
  • 41,986
  • 17
  • 75
  • 82
-1

By enabling multidex , Application will crash on Samsung devices S5,S6,So on. They have stopped the roll out of the update. So it looks like we are waiting for Samsung to roll out a new OS update with it fixed.

Or find a way to not use multi-dex in your app.

Aks4125
  • 4,522
  • 4
  • 32
  • 48
  • First time hear that. What is your source? – Alex Lipov Oct 16 '15 at 06:50
  • Source1 : Samsung http://developer.samsung.com/forum/thread/application-crushes-after-update-to-lollipop-on-samsung-galaxy-s5/202/278011?boardName=General&startId=zzzzz~ Source2 : Google https://code.google.com/p/android/issues/detail?id=155376 – Aks4125 Oct 16 '15 at 07:14
  • Don't see any response from either Samsung or Google. While it's great to mention that, from your answer one can conclude that it's official statement, but actually it's not. You've just seen someone complained about that issue. It is also very likely that the crash they experience caused because of their own bug or misuse. – Alex Lipov Oct 16 '15 at 07:26
  • 2
    I have a multi-dex application that works flawlessly on both S5 and S6 with Lollipop installed. Therefore, please edit your answer and instead of saying "By enabling multidex your app will crash on Samsung S5 and S6", write something like "There are some reports saying that multi-dex app crash on Samsung S5 and S6 running Lollipop" + provide the links in the answer itself. – Alex Lipov Oct 16 '15 at 07:33
-2

You should add below code to your app gradle file :

defaultConfig {

    applicationId 'pkg'
    minSdkVersion 
    targetSdkVersion 
    versionCode 
    versionName 

    // Enable MultiDexing:  https://developer.android.com/tools/building/multidex.html
    multiDexEnabled true
}

And add this dependency also :

  compile 'com.android.support:multidex:1.0.1'

Thanks..!!

AndiGeeky
  • 11,266
  • 6
  • 50
  • 66