Bug 53059 - Installing Google Play Services returns compile error javac code 2
Summary: Installing Google Play Services returns compile error javac code 2
Status: RESOLVED DUPLICATE of bug 55117
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components (show other bugs)
Version: Production (addons.xamarin.com)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jon Dick
URL:
Depends on:
Blocks:
 
Reported: 2017-03-04 19:13 UTC by Yves Delcoigne
Modified: 2017-09-28 14:26 UTC (History)
9 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 DUPLICATE of bug 55117

Description Yves Delcoigne 2017-03-04 19:13:54 UTC
Steps to reproduce:

1. Create a new Xamarin Forms project (Xamarin.Forms version 2.3.3.193)
2. Update the Android support libraries to 25.1.1
3. Install Xamarin.GooglePlayServices.Analytics NuGet package (version 42.1001.0)
4. Build the Android project.

Expected result:
Build succeeded

Actual result:
Build failed with error:
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2080,3): error MSB6006: "java.exe" exited with code 2

When enabling multi-dex, the build succeeds. However, when I analyze my dex method count with a method counter, I see I'm only at 36k methods.

Java version: 1.8.0_111
Android build-tools: 25
Updated proguard tools manually to newest version.

Environment: 
Visual Studio 2015
Xamarin for Visual Studio version 4.3
Xamarin.Android v7.1.0
Comment 1 Yves Delcoigne 2017-03-04 19:15:33 UTC
Java version is 64-bit.
Comment 2 smorsi27 2017-03-13 21:46:35 UTC
I have the same issue. Anyone taking a look at this?
Comment 3 smorsi27 2017-03-13 21:47:51 UTC
Here's some more info and I'm getting the java.exe exited with code 2: https://bugzilla.xamarin.com/show_bug.cgi?id=52944

as well as a different error. 

I tried to downgrade my packages to ver. 24 of the support libraries but the issue of java.exe exited with code 2 still persists.
Comment 4 bboals 2017-04-20 20:47:13 UTC
I am experiencing the same issue when I install the Xamarin.GooglePlayServices.Auth nuget package and its dependencies.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2068,3): error MSB6006: "java.exe" exited with code 2.

Java version: 1.8.0_131
Android build-tools: 25.02

Environment: 
Visual Studio 2017
Xamarin for Visual Studio version 4.4.0.34
Xamarin.Android v7.1.0


On a side note, I tried to enable to MultiDex to see if that might solve my problem but ran into:

Expecting class path separator ';' before '\Android\android-sdk\build-tools\25.0.2\lib\shrinkedAndroid.jar' in argument number 8
Comment 5 Shane 2017-04-20 22:33:39 UTC
There are a lot of quirks to getting MultiDex to work 

This might address what you're seeing with that particular exception
https://bugzilla.xamarin.com/show_bug.cgi?id=30362
Comment 7 Jon Bachelor 2017-08-30 16:04:58 UTC
One more instance of this to report, in case it's interesting that it is occurring on Visual Studio for Mac as well:


*******     VS Mac Details:     *******
=== Visual Studio Community 2017 for Mac ===

Version 7.1 (build 1297)
Installation UUID: 32f5116d-b5a5-47aa-a502-2f8043cbe7da
Runtime:
	Mono 5.2.0.215 (d15-3/da80840) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 502000215

=== NuGet ===

Version: 4.3.0.2418

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	2.0.0
	2.0.0-preview2-25407-01
	1.1.1
	1.0.4
	1.0.0
SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks
SDK Versions:
	2.0.0
	2.0.0-preview3-006912
	2.0.0-preview2-006497
	1.0.3
	1.0.0-preview2-003121
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.5
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.3.3 (12175.1)
Build 8E3004b

=== Xamarin.iOS ===

Version: 10.12.0.20 (Visual Studio Community)
Hash: 80b8487d
Branch: d15-3
Build date: 2017-08-18 16:07:26-0400

=== Xamarin.Android ===

Version: 7.4.0.21 (Visual Studio Community)
Android SDK: /Users/jbachelor/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)
		7.0 (API level 24)
		7.1 (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.6
SDK Build Tools Version: 26.0.1

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin.Mac ===

Version: 3.6.0.19 (Visual Studio Community)

=== Xamarin Inspector ===

Version: 1.2.2
Hash: b71b035
Branch: d15-1
Build date: Fri, 21 Apr 2017 17:57:12 GMT

=== Build Information ===

Release ID: 701001297
Git revision: 9c5299666538b2f8baf501418a5c064d784d64da
Build date: 2017-08-07 11:29:35-04
Xamarin addins: 3bb0c32a14f1b7e368bf5ac53a84c3581c019391
Build lane: monodevelop-lion-d15-3

=== Operating System ===

Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
    Thu Jun 15 17:36:27 PDT 2017
    root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64








*******     Hopefully some Helpful Output From Building App:     *******
Target _CompileToDalvikWithDx:
    /usr/bin/java -Xmx1G -jar /Users/jbachelor/Library/Developer/Xamarin/android-sdk-macosx/build-tools/26.0.1/lib/dx.jar --no-strict --dex --output=obj/Debug/android/bin obj/Debug/android/bin/classes /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v7.1/mono.android.jar obj/Debug/__library_projects__/FormsViewGroup/library_project_imports/formsviewgroup.jar obj/Debug/__library_projects__/Xamarin.Android.Support.Animated.Vector.Drawable/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.Compat/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.Core.UI/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.Core.Utils/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.Design/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.Fragment/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.Media.Compat/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.Transition/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.Vector.Drawable/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.v4/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.v7.AppCompat/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.v7.CardView/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.v7.MediaRouter/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.v7.Palette/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Android.Support.v7.RecyclerView/library_project_imports/bin/classes.jar obj/Debug/__library_projects__/Xamarin.Firebase.Analytics/library_project_imports/classes.jar obj/Debug/__library_projects__/Xamarin.Firebase.Analytics.Impl/library_project_imports/classes.jar obj/Debug/__library_projects__/Xamarin.Firebase.Common/library_project_imports/classes.jar obj/Debug/__library_projects__/Xamarin.Firebase.Iid/library_project_imports/classes.jar obj/Debug/__library_projects__/Xamarin.GooglePlayServices.Analytics/library_project_imports/classes.jar obj/Debug/__library_projects__/Xamarin.GooglePlayServices.Analytics.Impl/library_project_imports/classes.jar obj/Debug/__library_projects__/Xamarin.GooglePlayServices.Base/library_project_imports/classes.jar obj/Debug/__library_projects__/Xamarin.GooglePlayServices.Basement/library_project_imports/classes.jar obj/Debug/__library_projects__/Xamarin.GooglePlayServices.TagManager.V4.Impl/library_project_imports/classes.jar obj/Debug/__library_projects__/Xamarin.GooglePlayServices.Tasks/library_project_imports/classes.jar 
    
    trouble writing output: Too many field references to fit in one dex file: 68314; max is 65536.
    You may try using multi-dex. If multi-dex is enabled then the list of classes for the main dex list is too large.
    References by package:
         2 android.accounts
        28 android.app
         1 android.content
        37 android.content.pm
        10 android.content.res
         3 android.database
        42 android.graphics
         2 android.media
         1 android.media.browse
         2 android.net
        19 android.os
         3 android.print
         8 android.runtime
         1 android.support.annotation
      2237 android.support.compat
      2237 android.support.coreui
      2237 android.support.coreutils
      2237 android.support.design
       107 android.support.design.internal
       700 android.support.design.widget
      2237 android.support.fragment
      2450 android.support.graphics.drawable
      2237 android.support.graphics.drawable.animated
      2237 android.support.mediacompat
      2416 android.support.transition
      2237 android.support.v4
        13 android.support.v4.accessibilityservice
        17 android.support.v4.animation
       886 android.support.v4.app
       115 android.support.v4.content
         1 android.support.v4.content.pm
         1 android.support.v4.content.res
        11 android.support.v4.graphics
        41 android.support.v4.graphics.drawable
         4 android.support.v4.hardware.display
        12 android.support.v4.hardware.fingerprint
        10 android.support.v4.internal.view
       405 android.support.v4.media
       393 android.support.v4.media.session
        10 android.support.v4.net
        19 android.support.v4.os
        63 android.support.v4.print
        10 android.support.v4.provider
        55 android.support.v4.text
         6 android.support.v4.text.util
       118 android.support.v4.util
       434 android.support.v4.view
       138 android.support.v4.view.accessibility
         8 android.support.v4.view.animation
       496 android.support.v4.widget
       605 android.support.v7.app
      2237 android.support.v7.appcompat
      2237 android.support.v7.cardview
         8 android.support.v7.content.res
        88 android.support.v7.graphics
        18 android.support.v7.graphics.drawable
       437 android.support.v7.media
      2237 android.support.v7.mediarouter
      2237 android.support.v7.palette
      2237 android.support.v7.recyclerview
         1 android.support.v7.text
         2 android.support.v7.transition
       124 android.support.v7.util
        79 android.support.v7.view
       249 android.support.v7.view.menu
      1482 android.support.v7.widget
        89 android.support.v7.widget.helper
         1 android.support.v7.widget.util
         5 android.text
         1 android.text.util
         2 android.transition
        12 android.util
        19 android.view
         8 android.view.accessibility
         1 android.view.inputmethod
        14 android.widget
      2231 com.google.android.gms
        20 com.google.android.gms.actions
        14 com.google.android.gms.ads.identifier
      2329 com.google.android.gms.analytics
        14 com.google.android.gms.analytics.ecommerce
        41 com.google.android.gms.auth.api.signin
        10 com.google.android.gms.auth.api.signin.internal
      2231 com.google.android.gms.base
        98 com.google.android.gms.common
        99 com.google.android.gms.common.api
        41 com.google.android.gms.common.data
        46 com.google.android.gms.common.images
       162 com.google.android.gms.common.internal
         1 com.google.android.gms.common.internal.safeparcel
         4 com.google.android.gms.common.server
        33 com.google.android.gms.common.stats
        29 com.google.android.gms.common.util
        27 com.google.android.gms.dynamic
        19 com.google.android.gms.dynamite
         2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags
        16 com.google.android.gms.flags.impl
         4 com.google.android.gms.iid
      2307 com.google.android.gms.internal
         5 com.google.android.gms.location.places
      2257 com.google.android.gms.measurement
      2231 com.google.android.gms.measurement.impl
         6 com.google.android.gms.security
      2618 com.google.android.gms.tagmanager
      2279 com.google.android.gms.tasks
      2262 com.google.firebase
        66 com.google.firebase.analytics
         2 com.google.firebase.auth
      2308 com.google.firebase.iid
      2231 com.hunter.luxortest
         1 com.xamarin.forms.platform.android
         7 java.lang
         7 java.lang.annotation
         1 java.nio
         6 java.util
         4 java.util.concurrent
         2 md5048a04284979bff265231e98628579ce
        10 md50a429594d0894eb20c31b81b4e1d1aaf
         4 md526b7ac14cffc1a788e82c7b73f3add08
        36 md5270abb39e60627f0f200893b490a1ade
         4 md531f8cc8d4d39b2fa02686ee0eb368905
         4 md546c06bd645a1215106524147032ed669
        14 md54aebcf0699d682e0a1ce37a8ee487172
         8 md55430eeafbf000a5ac5c6dc7e4c10488b
         4 md55f37f9e3fb497ca422f569deaf0bb0c6
         2 md579e3c23327d9e96c8c838e6e43108fb9
         2 md5962860d42c54f09775aa7df25d74949f
       160 md5b60ffeb829f638581ab2bb9b1a7f4f3f
         2 md5fb6c3e1bb2e377d2f1426c501b03a329
         6 mono
         1 mono.android
         4 mono.android.accessibilityservice
         2 mono.android.accounts
        12 mono.android.animation
        31 mono.android.app
         2 mono.android.bluetooth
        20 mono.android.content
         2 mono.android.database.sqlite
         6 mono.android.drm
         6 mono.android.gesture
         2 mono.android.graphics
         2 mono.android.graphics.drawable
         8 mono.android.hardware
         2 mono.android.hardware.display
         2 mono.android.hardware.input
         2 mono.android.inputmethodservice
         8 mono.android.location
        60 mono.android.media
        16 mono.android.media.audiofx
         2 mono.android.media.effect
         2 mono.android.media.midi
         2 mono.android.media.session
         2 mono.android.media.tv
         2 mono.android.net
         6 mono.android.net.nsd
         2 mono.android.net.sip
        18 mono.android.net.wifi.p2p
         2 mono.android.nfc
        10 mono.android.os
        10 mono.android.preference
         2 mono.android.renderscript
         6 mono.android.runtime
         6 mono.android.sax
         2 mono.android.speech
         4 mono.android.speech.tts
        12 mono.android.support.design.widget
         2 mono.android.support.transition
         4 mono.android.support.v4.app
         4 mono.android.support.v4.content
         2 mono.android.support.v4.media.session
         2 mono.android.support.v4.os
        18 mono.android.support.v4.view
         4 mono.android.support.v4.view.accessibility
        12 mono.android.support.v4.widget
         6 mono.android.support.v7.app
         2 mono.android.support.v7.graphics
         2 mono.android.support.v7.media
        32 mono.android.support.v7.widget
         2 mono.android.text
         2 mono.android.transition
        72 mono.android.view
         4 mono.android.view.accessibility
         2 mono.android.view.animation
         2 mono.android.view.textservice
         8 mono.android.webkit
        72 mono.android.widget
         2 mono.com.google.android.gms.common.api
         2 mono.com.google.android.gms.common.images
         2 mono.com.google.android.gms.security
         2 mono.com.google.android.gms.tagmanager
         6 mono.com.google.android.gms.tasks
         4 mono.java.lang
         2 mono.java.util
         2 mono.javax.xml.transform
         2 opentk
         2 opentk.platform.android
         2 opentk_1_0
         2 opentk_1_0.platform.android
         1 org.json
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1973,3): error MSB6006: "java" exited with code 2.
Done building target "_CompileToDalvikWithDx" in project "Luxor.Droid.csproj" -- FAILED.

Done building project "Luxor.Droid.csproj" -- FAILED.

Build FAILED.
Comment 8 Pavel Fedotovsky 2017-09-11 20:56:11 UTC
Enabling MultiDex fixed the issue for me.
Comment 9 Jon Dick 2017-09-28 14:26:54 UTC

*** This bug has been marked as a duplicate of bug 55117 ***