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
Posts
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
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.
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.
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.
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.
same problem here and nothing from above works....
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.
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.
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:
Target _CompileToDalvik:
Done building target "_CompileToDalvik" in project "theAppMobile.Droid.csproj" -- FAILED.
Please, help, cannot release the app. Thank you everyone!!!!
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.
Is there a way to update Proguard?
I think the problem comes with Google Play Services 25.0.0.0 and not from Proguard. Hopefully Xamarin will update this component soon..
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.
Removing all API Level 23 from Android SDK Manager solved the problem! Now I can compile in Release with ProGuard again
Thanks Ljusnan!
I update Xamarin.Android to 3.11.837. The same problem. Finally I update my android tools in android sdk. Solved.
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.
I am creating a Barcode scanner app, and made the error disappear by removing Xamarin.Android.Support v$4
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 .
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?
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)?
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.
Create file named
proguard.cfg
inside Android project in the solution. Right click and setBuild Action
toProguardConfig
.Add the following lines:
Amend the above according to type of errors you're getting
Make sure you save file as UTF-8 and NOT UTF-8 BOM
@SalemKorayem - your suggestion worked for me, only after paying attention to your tip on encoding.
@Korayem where do I set Build Action to ProguardConfig?
@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
@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.
@Kora> @Korayem said:
Thank for your help. It works fine for me
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
@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
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.
Any solutions, I tried all the mention options.
I have downloaded latest proguard from sourceforge, but no success.
@eddyizm
@hernani.fernandes
yes
it's working good
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?
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
Complete proguard-android.txt File
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/