I added Google play services to my project for maps but now keep getting this error "java.exe" exited with code 2. I am not sure if it is different from "java.exe" exited with code 1 but I have tried all the suggestions online My heap size is 1G. My target version is 21, I have clean rebuild etc.. When I click on the error it takes me to this CompileToDalvik. How can I resolve this? Even if I remove google play services I still get this error( clean / refresh rebuild etc..)
-
Are you using Eclipse? How do you run your project? – eduyayo Jul 28 '15 at 11:59
-
I uses xamarin and I get this error when I try to build my project – Charl Potgieter Jul 29 '15 at 20:35
8 Answers
We had similar issues and nailed it down to our app going over 64k (65,536) methods limit which could be what's happening when you reference google play services.
Enabling multidex resolved our issue so may be worth trying.
Google Multi-Dex Reference: http://developer.android.com/tools/building/multidex.html

- 903
- 2
- 13
- 32
-
yes it seems this was the problem. The solution Is to install only the necessary packets from google maps. through nugget manager. I hope this can help somebody else too – Charl Potgieter Feb 05 '16 at 08:14
Using Visual Studio and Xamarin I got this error because I had a wrong path for the Keystore in the .csproj file, and for some reason this path did not get updated while changing the path for the Keystore in the Visual Studio GUI. Manual correcting the path in the .csproj file solved it for me.

- 343
- 3
- 11
None of the others answers worked for me. What worked for me (but I don't know why) was to empty my bin and obj directories before doing a rebuild.

- 4,706
- 2
- 21
- 26
-
That works like a charm. None of the others answers worked for my as well. Thanks @Tokn! – casillas Feb 10 '17 at 16:37
I've seen this error recently. It was caused by an invalid (layout) xml file. Unfortunately, you don't get more hints where exactly the problem is :( I'd try to exclude the xml files one by one and check if the build succeeds without a certain file. Good luck!
Edit : I'm not even sure it actually was a layout xml file, maybe it has been a style or color xml :/ Any recent changes to one of those?

- 1,275
- 10
- 13
-
2No this is not the problem. If I remove the google play service the application works. – Charl Potgieter Aug 04 '15 at 07:44
Clean the Bin and the Obj folders, and rebuild again. If it doesn't work please check different JDK version.

- 513
- 5
- 21
I had this error when switching from VS Mac to VS Windows.
Here the topic Switching From VS Mac To VS Windows got “java.exe” exited with code 2
The issue was comming from the Android.csproj and the Keystore Path.
It was set to my Mac Path even if I had already changed it on
VSWindows AndroidProject => Properties => Signin
So I removed this lines on Android.csproj (edited with third text editor):
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>YourMacPath/Alias.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>Password</AndroidSigningStorePass>
<AndroidSigningKeyAlias>Alias</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>AliasPassword</AndroidSigningKeyPass>
On debug & release Part.
Then you can edit them on VS Windows.
Hope I helped someone. See ya

- 2,442
- 3
- 19
- 24
Now in VS 2022, I had the very same problem and nothing would work. I had noticed that, at least in my case, problem started when I accidentally lost the certificate from the keystore. For debugging mode I just took the signature out since it provides it's own. However, I will need to re-add the key once I change to release. Once the proper key is found in the keystore, the problem is resolved. Apparently that error code is useless.

- 67
- 5