java.exe exited with code 1 (Xamarin.Android.Common.targets)

We have been working on a cross-platform iOS/Android application and our builds are handled via TFS 2012. On a pretty regular basis, our builds fail due to the following error:

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets (1138): "java.exe" exited with code 1.

Inspecting the above targets file at the specified line, the intermittent failures occur on CompileToDalvik. The error logs don't provide any useful information other than this:

_CompileDex:
JavaSourceFiles:
JavaLibraries:
ExternalJavaLibraries:
C:\Program Files\Java\jdk1.6.0_33\bin\java.exe -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\17.0.0\lib\dx.jar" --no-strict --dex --output=obj\Release\android\bin\classes.dex obj\Release\android\bin\classes "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\mono.android.jar" C:\Builds\1..\obj\Release__library_projects__\ab_sherlock.jar C:\Builds\1..\obj\Release__library_projects__\android-support-v4.jar
3>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1138,3): error MSB6006: "java.exe" exited with code 1.

Does anybody have any idea why these intermittent failures occur? Is there anything we can do to get more useful error information?

Thanks!
Scott

«1

Posts

  • SebastianSeidel.9226SebastianSeidel.9226 DEInsider, University ✭✭✭✭

    You can try to find some more details about the error with diagnostic turned on. http://docs.xamarin.com/guides/android/deployment,_testing,_and_metrics/diagnostics#1-diagnostic-msbuild-output

  • FraelReinosoFraelReinoso USMember ✭✭

    I was facing this problem, it was caused by 2 project references i had "Mono.Android.GoogleMaps y Mono.Android.Support.v13". As soon as i deactivated them, the project compiled and i was able to debug it.

  • ArthurDentArthurDent USMember ✭✭

    I tried all the suggestions I found around the web such as deleting the bin and obj directories, remaking the solution file, re-pulling the entire solution from the source-code repository, etc. etc... but none of these worked in my case.

    Then I tried updating my Java installation, and in my case that fixed it.

  • I had the same problem and in my case, i just needed to Clean and Rebuild the project.

  • AntoineBeckerAntoineBecker FRMember

    It's been the third time I have to problem, each time I found this thread.

    So solution for me was to go to the project options -> Android Build -> Advanced and remove the "2GB" for the Java heap size.

  • RAPIDDevRAPIDDev USMember

    I resolved this by manually overriding the java heap size:
    In Xamarin Studio:
    Right-click on Project
    Options
    Android Build
    Advanced
    Set Java Heap Size to 1G (Or larger depending)

    The project now builds.

    Hope this helps. :)

  • JuanCarlosUsquianoJuanCarlosUsquiano COMember, University

    same problem here and nothing from above works....

  • JuanCarlosUsquianoJuanCarlosUsquiano COMember, University

    Ok, it works if in project options in android build advanced, heap size is set to 1G as said above!!! it only works with that value!!! it is weird!!

  • Same problem here ..I try all the above scenarios .But nothing is working

  • I also tried everything as suggested above.
    anybody with different solution.Please reply.

  • MakarandKhairnarMakarandKhairnar INMember ✭✭

    Hi there,
    I am also getting "java.exe" exited with code 1 error.

    Can anyone help me out to resolve this.

    Attached is my build output.

  • AlexPryiomkaAlexPryiomka USMember

    Hi Forum, I have the same error and cannot find answer. I am getting error MSB6006: "java.exe" exited with code 1 as well. Bellow is the build output:
    Target _CompileJava:

    C:\Program Files\Java\jdk1.7.0_75\\bin\javac.exe -J-Dfile.encoding=UTF8 -d obj\Release\android\bin\classes -classpath "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.1\mono.android.jar;obj\Release\__library_projects__\FloatingActionButton-Xamarin\library_project_imports\bin\classes.jar;C:\ProgramFiles\Android\android-sdk\extras\android\support\multidex\library\libs\android-support-multidex.jar;C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v4\22.2.1\embedded\classes.jar;C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v4\22.2.1\embedded\libs\internal_impl-22.2.1.jar;C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v7.AppCompat\22.2.1\embedded\classes.jar;C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v7.CardView\22.2.1\embedded\classes.jar;C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v7.RecyclerView\22.2.1\embedded\classes.jar;C:\Users\Alex\AppData\Local\Xamarin\GooglePlayServices.Base\25.0.0\embedded\classes.jar;C:\Users\Alex\AppData\Local\Xamarin\GooglePlayServices.Maps\25.0.0\embedded\classes.jar" -bootclasspath C:\ProgramFiles\Android\android-sdk\platforms\android-23\android.jar -encoding UTF-8 "@C:\Users\Alex\AppData\Local\Temp\tmpFCA2.tmp" 
    
    Note: Some input files use or override a deprecated API.
    
    Note: Recompile with -Xlint:deprecation for details.
    
    Note: Some input files use unchecked or unsafe operations.
    
    Note: Recompile with -Xlint:unchecked for details.
    

    Target _CompileToDalvik:

    C:\Program Files\Java\jdk1.7.0_75\\bin\java.exe -jar C:\ProgramFiles\Android\android-sdk\tools\proguard\lib\proguard.jar -include C:\ProgramFiles\Android\android-sdk\tools\proguard\proguard-android.txt -include obj\Release\proguard\proguard_xamarin.cfg -include obj\Release\proguard\proguard_project_references.cfg -include obj\Release\proguard\proguard_project_primary.cfg "-injars 'obj\Release\proguard\__proguard_input__.jar';'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.1\mono.android.jar';'C:\ProgramFiles\Android\android-sdk\extras\android\support\multidex\library\libs\android-support-multidex.jar';'obj\Release\__library_projects__\FloatingActionButton-Xamarin\library_project_imports\bin\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v4\22.2.1\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v4\22.2.1\embedded\libs\internal_impl-22.2.1.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v7.AppCompat\22.2.1\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v7.CardView\22.2.1\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v7.RecyclerView\22.2.1\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\GooglePlayServices.Base\25.0.0\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\GooglePlayServices.Maps\25.0.0\embedded\classes.jar'" "-libraryjars 'C:\ProgramFiles\Android\android-sdk\platforms\android-23\android.jar'" -outjars "obj\Release\proguard\__proguard_output__.jar" 
    
    PROGUARD : warning : com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in class android.app.Notification
    
          You should check if you need to specify additional program jars.
    
    PROGUARD : warning : there were 1 unresolved references to program class members.
    
             Your input classes appear to be inconsistent.
    
             You may need to recompile them and try again.
    
             Alternatively, you may have to specify the option 
    
             '-dontskipnonpubliclibraryclassmembers'.
    
    java.io.IOException: Please correct the above warnings first.
    
        at proguard.Initializer.execute(Initializer.java:321)
    
        at proguard.ProGuard.initialize(ProGuard.java:211)
    
        at proguard.ProGuard.execute(ProGuard.java:86)
    
        at proguard.ProGuard.main(ProGuard.java:492)
    
    Picked up JAVA_TOOL_OPTIONS:  -Dfile.encoding=UTF8
    
    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1624,3): error MSB6006: "java.exe" exited with code 1.
    

    Done building target "_CompileToDalvik" in project "theAppMobile.Droid.csproj" -- FAILED.

    Please, help, cannot release the app. Thank you everyone!!!!

  • LjusnanLjusnan DEMember ✭✭✭

    Same problem here. Seems like Google Play Services 25.0.0.0 and Proguard is a bad combination? I disable Proguard and the build works.

  • AlexPryiomkaAlexPryiomka USMember

    Is there a way to update Proguard?

  • LjusnanLjusnan DEMember ✭✭✭

    I think the problem comes with Google Play Services 25.0.0.0 and not from Proguard. Hopefully Xamarin will update this component soon..

  • LjusnanLjusnan DEMember ✭✭✭

    A Xamarin engineer told me that API level 23 support is currently in preview. So I uninstalled API level 23 in the SDK manager and it is working now.

  • PiccoPicco USMember ✭✭

    Removing all API Level 23 from Android SDK Manager solved the problem! Now I can compile in Release with ProGuard again

    Thanks Ljusnan!

  • RyanWangRyanWang USMember

    I update Xamarin.Android to 3.11.837. The same problem. Finally I update my android tools in android sdk. Solved.

  • ManInTheLoftManInTheLoft GBBeta, University ✭✭

    Although I tried adding/removing the API's I found it was the heap size that had an effect. Setting it to 1G and NOT 1GB stopped the error.

    MITL

  • Same problem here.
    I update to xamarin.android.Wear 1.3.0.0 and Project doesn't build.

  • SamRaSamRa USMember

    I am creating a Barcode scanner app, and made the error disappear by removing Xamarin.Android.Support v$4

  • RaphicRaphic USMember

    I m stucked with the same Problem,

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

    tried running the application with 22API Level , Java Heap Size is 1G ,still same Problem

    Please guyz help me out with this .

  • elenaorelelenaorel USMember

    for all my apps but one "1G" suggestion worked. One of my application has addition SQLite libraries - I was not able to solve the "java.exe" exited with code 1 by setting Java heap size to 1G. Any suggestions to make Java heap size bigger than 1G?

  • elenaorelelenaorel USMember

    Actually, I have tried my apps (I have released all of them in Dec 2015 without problems). Today all of them are not buildable ("java.exe" exited with code 1) - all of them. They are on google play - obviously I was able to build them 3 days ago. Is it related to Xamarin.Android.Support.V4 (23.1.1.0)?

  • elenaorelelenaorel USMember

    Hoh, the solution was to downgrade Windows 10 to Windows 8.1. All projects are back... Fortunately I had a 30 days gap to reverse my Windows 10. I would be happy to learn more about Java memory settings in Windows 10 before I try my Xamarin projects in Window 10 again.

  • rossjempsonrossjempson AUMember ✭✭

    @SalemKorayem - your suggestion worked for me, only after paying attention to your tip on encoding.

  • FranciscoGGFranciscoGG ESMember ✭✭

    @Korayem said:
    Create file named proguard.cfg inside Android project in the solution. Right click and set Build Action to ProguardConfig.

    Add the following lines:

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

    Amend the above according to type of errors you're getting

    Make sure you save file as UTF-8 and NOT UTF-8 BOM

    @Korayem where do I set Build Action to ProguardConfig?

  • DylanSchoenmakersDylanSchoenmakers NLMember ✭✭

    @FranciscoGG after you add the cfg file you can right click to file on the left hand side in the solution explorer to set the build action. See also: https://developer.xamarin.com/guides/android/deployment,testing,_and_metrics/publishing_an_application/part_1-_preparing_an_application_for_release/#ProGuard

  • FranciscoGGFranciscoGG ESMember ✭✭

    @DylanSchoenmakers your solution is not working for me...I get these errors:

    8>COMPILETODALVIK : error : Could not create the Java Virtual Machine.
    8>COMPILETODALVIK : error : A fatal exception has occurred. Program will exit.

  • MrFourITMrFourIT USMember

    @Kora>; @Korayem said:

    Create file named proguard.cfg inside Android project in the solution. Right click and set Build Action to ProguardConfig.

    Add the following lines:

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

    Amend the above according to type of errors you're getting

    Make sure you save file as UTF-8 and NOT UTF-8 BOM

    Thank for your help. It works fine for me :D

  • ArvindrajaArvindraja INMember ✭✭✭

    The Perfect Solution for me

    downloaded the proguard file and unzip it

    url to download file
    https://sourceforge.net/projects/proguard/files/proguard/4.6/

    go to this location:
    C:\Users\yourUsername\AppData\Local\Android\android-sdk\tools
    here you will find proguard folder rename it to proguard.old

    and paste the downloaded unzip folder(folder with name proguard) there inside the tools folder.
    rebuilt and run project,

    after doing this if you won't get the solution do the last step also
    last step is:
    open the proguard.old folder copy all files from here and paste in the proguard folder(skip the same files if you get the warning)

    Note :Everything you need to do inside this location only
    C:\Users\yourUsername\AppData\Local\Android\android-sdk\tools

    hope it help you :)

  • AshwinJeyananadAshwinJeyananad INMember ✭✭

    @DylanSchoenmakers Thanks for sharing the links.

    https://developer.xamarin.com/guides/android/deployment,testing,_and_metrics/publishing_an_application/part_1-_preparing_an_application_for_release/

    https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/proguard/

    Hi All,

    I am facing the issue like above in debug mode. I tried the above solution but still issue persists.
    Have any one faced the same issue?

    Error "javac.exe" exited with code -1073741701.

    any ideas? Thanks in advance.

  • Now I'm facing this error:
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Tool exited with code: 1. Output: ProGuard, version 5.3.2

  • eddyizmeddyizm USMember ✭✭

    This proguard issue is such a cluster. Why are can't we get a decent release build solution? I tried to add firebase messenging and everything has gone sideways. I made all the suggested fixes above and everywhere else I could find and still, nothing works. Debug works, release with proguard bombs and when I am able to build it literally just crashes on opening. Very disheartening.

  • Abhijeet_SuryaAbhijeet_Surya USMember ✭✭✭
    edited March 2017

    Any solutions, I tried all the mention options.

    I have downloaded latest proguard from sourceforge, but no success.

    @eddyizm
    @hernani.fernandes

  • sureshrajanasureshrajana USMember ✭✭

    @RAPIDDev said:
    I resolved this by manually overriding the java heap size:
    In Xamarin Studio:
    Right-click on Project
    Options
    Android Build
    Advanced
    Set Java Heap Size to 1G (Or larger depending)

    The project now builds.

    Hope this helps. :)

    yes :) it's working good

  • negazirnegazir USMember ✭✭

    1.tried to update proguard to 5.3 version manualy

    2.to update jdk 8, to install either x64 or x86 or both

    3.to change the java memory to 1g , 4g, 500 m

    4.to turn on multi-desk

    to edit the proguard-android.txt by adding

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

    -dontwarn com.google.android.gms.**
    (These just ignore proguard, google play doesnt accept it.)

    ANY OTHER VARIANTS HERE?

  • BrandonMinnickBrandonMinnick USXamarin Team Xamurai

    I had a problem where Proguard was removing the Google Play Services libraries from my app.

    I had to add the following lines of text to the proguard-android.txt file found in this folder:
    /(Path to your Android SDK Folder)/tools/proguard

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

    Complete proguard-android.txt File

    -keep public class com.google.android.gms.* { public *; }
    -dontwarn com.google.android.gms.**
    
    # This is a configuration file for ProGuard.
    # http://proguard.sourceforge.net/index.html#manual/usage.html
    
    -dontusemixedcaseclassnames
    -dontskipnonpubliclibraryclasses
    -verbose
    
    # Optimization is turned off by default. Dex does not like code run
    # through the ProGuard optimize and preverify steps (and performs some
    # of these optimizations on its own).
    -dontoptimize
    -dontpreverify
    # Note that if you want to enable optimization, you cannot just
    # include optimization flags in your own project configuration file;
    # instead you will need to point to the
    # "proguard-android-optimize.txt" file instead of this one from your
    # project.properties file.
    
    -keepattributes *Annotation*
    -keep public class com.google.vending.licensing.ILicensingService
    -keep public class com.android.vending.licensing.ILicensingService
    
    # For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
    -keepclasseswithmembernames class * {
        native <methods>;
    }
    
    # keep setters in Views so that animations can still work.
    # see http://proguard.sourceforge.net/manual/examples.html#beans
    -keepclassmembers public class * extends android.view.View {
       void set*(***);
       *** get*();
    }
    
    # We want to keep methods in Activity that could be used in the XML attribute onClick
    -keepclassmembers class * extends android.app.Activity {
       public void *(android.view.View);
    }
    
    # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
    -keepclassmembers enum * {
        public static **[] values();
        public static ** valueOf(java.lang.String);
    }
    
    -keepclassmembers class * implements android.os.Parcelable {
      public static final android.os.Parcelable$Creator CREATOR;
    }
    
    -keepclassmembers class **.R$* {
        public static <fields>;
    }
    
    # The support library contains references to newer platform versions.
    # Don't warn about those in case this app is linking against an older
    # platform version.  We know about them, and they are safe.
    -dontwarn android.support.**
    
    # Understand the @Keep support annotation.
    -keep class android.support.annotation.Keep
    
    -keep @android.support.annotation.Keep class * {*;}
    
    -keepclasseswithmembers class * {
        @android.support.annotation.Keep <methods>;
    }
    
    -keepclasseswithmembers class * {
        @android.support.annotation.Keep <fields>;
    }
    
    -keepclasseswithmembers class * {
        @android.support.annotation.Keep <init>(...);
    }
    
  • AlaaBakhit.0408AlaaBakhit.0408 USMember

    Updating proguard by downloading latest version 5.3.3 , but with keeping proguard-android.txt files worked fine with me, what you can do is you can change the build log to verbose and check the error message, i found two errors, 1) the encoding of proguard.cfg was set to utf8 which is unreadable, 2) the proguard version support <52.0.
    you can download newest proguard from here : https://sourceforge.net/projects/proguard/files/proguard/

«1
Sign In or Register to comment.