error MSB6006: “java.exe” exited with code 1. – Xamarin.Android – How to solve ?

When I was trying to build an Xamarin Android app with Release configuration in Visual Studio 2017, I got an error saying..

error MSB6006: “java.exe” exited with code 1.

Then I looked for how to solve the error and I found that the issue happen because of Proguard is enabled.

1

Image 1 : Android options for release configuration

Then I found 2 solutions to solve the issue.

  1. Set Java Max Heap Size in Android options.
  2. Change format of Java Max Heap Size in Android options.(Use M/G instead of MB/GB)
  3. Add a  custom Proguard configuration file.

I tried first 2 options but, it didn’t solve the issue.

2

Image 2 : Change max heap size manually (option 1 and 2)

Final Solution.

The issue solved when I add a Proguard configuration file manually.

Steps to add a Proguard configuration file manually.

    1. Go to Android project
    2. Create new file call proguard.cfg
    3. Right Click on proguard.cfg file and go to properties.
    4. Change build action to Proguard Configuration.
    5. Open the file and add below code..
    6. Save and Re-Build the Android Project..
3

Image 3 : Change build action of proguard.cfg

-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**

 

4

Image 4 : code in proguard.cfg

 

Thanks !

 

Reference

https://forums.xamarin.com/discussion/9305/java-exe-exited-with-code-1-xamarin-android-common-targets

https://stackoverflow.com/questions/38147828/java-exe-exited-with-code-1-proguard-issue

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s