Charl Potgieter
Charl Potgieter

Reputation: 211

"java.exe" exited with code 2

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..)

Upvotes: 6

Views: 10160

Answers (8)

user3988148
user3988148

Reputation: 87

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.

Upvotes: 0

G Clovs
G Clovs

Reputation: 3162

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

Upvotes: 0

Ren&#233; AD
Ren&#233; AD

Reputation: 374

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.

Upvotes: 3

KrustyGString
KrustyGString

Reputation: 1003

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

Upvotes: 8

Malik Aqib
Malik Aqib

Reputation: 513

Clean the Bin and the Obj folders, and rebuild again. If it doesn't work please check different JDK version.

Upvotes: 0

Suchith
Suchith

Reputation: 1527

Increasing the Java Heap Size to 1G is worked for me!

Upvotes: 0

ED-209
ED-209

Reputation: 4746

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.

Upvotes: 2

Daniel Veihelmann
Daniel Veihelmann

Reputation: 1487

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?

Upvotes: 0

Related Questions