Xamarin.Android error MSB6006: "java.exe" exited with code 1 after upgrade solution from VS2019 to VS2022

Mattia Vicari 16 Reputation points
2022-07-19T22:16:08.997+00:00

Hi all,
I have upgraded a Xamarin project from VS2019 to VS2022.
I have also updated some nuget packages too but now I'm not able to build the Android project. I always get the error MSB6006: "java.exe" exited with code 1.

I read in another post that it maybe depends on a bad configuration of Proguard... but I'm not using Proguard for debug (also the release build fails).

Below the list of dependences extracted from the project.assets.json file:

{  
	"monoandroid12.0": {  
		"dependencies": {  
			"Com.OneSignal": {  
				"target": "Package",  
				"version": "[3.10.6, )"  
			},  
			"Microsoft.Net.Http": {  
				"target": "Package",  
				"version": "[2.2.29, )"  
			},  
			"Otp.NET": {  
				"target": "Package",  
				"version": "[1.2.2, )"  
			},  
			"Plugin.InAppBilling": {  
				"target": "Package",  
				"version": "[4.0.2, )"  
			},  
			"SkiaSharp.Views.Forms": {  
				"target": "Package",  
				"version": "[2.88.0, )"  
			},  
			"System.IO.Compression.ZipFile": {  
				"target": "Package",  
				"version": "[4.3.0, )"  
			},  
			"Wiry.Base32": {  
				"target": "Package",  
				"version": "[1.1.1, )"  
			},  
			"Xamarin.Android.Support.Compat": {  
				"target": "Package",  
				"version": "[28.0.0.3, )"  
			},  
			"Xamarin.Android.Support.CustomTabs": {  
				"target": "Package",  
				"version": "[28.0.0.3, )"  
			},  
			"Xamarin.Android.Support.Design": {  
				"target": "Package",  
				"version": "[28.0.0.3, )"  
			},  
			"Xamarin.Android.Support.v4": {  
				"target": "Package",  
				"version": "[28.0.0.3, )"  
			},  
			"Xamarin.Android.Support.v7.AppCompat": {  
				"target": "Package",  
				"version": "[28.0.0.3, )"  
			},  
			"Xamarin.Android.Support.v7.CardView": {  
				"target": "Package",  
				"version": "[28.0.0.3, )"  
			},  
			"Xamarin.Android.Support.v7.MediaRouter": {  
				"target": "Package",  
				"version": "[28.0.0.3, )"  
			},  
			"Xamarin.AndroidX.Core": {  
				"target": "Package",  
				"version": "[1.7.0.2, )"  
			},  
			"Xamarin.AndroidX.Lifecycle.LiveData": {  
				"target": "Package",  
				"version": "[2.3.1.3, )"  
			},  
			"Xamarin.AndroidX.MediaRouter": {  
				"target": "Package",  
				"version": "[1.3.0, )"  
			},  
			"Xamarin.AndroidX.Work.Runtime": {  
				"target": "Package",  
				"version": "[2.7.0, )"  
			},  
			"Xamarin.Build.Download": {  
				"target": "Package",  
				"version": "[0.7.1, )"  
			},  
			"Xamarin.Essentials": {  
				"target": "Package",  
				"version": "[1.7.3, )"  
			},  
			"Xamarin.FFImageLoading.Svg.Forms": {  
				"target": "Package",  
				"version": "[2.4.11.982, )"  
			},  
			"Xamarin.Forms": {  
				"target": "Package",  
				"version": "[5.0.0.2478, )"  
			},  
			"Xamarin.GooglePlayServices.Location": {  
				"target": "Package",  
				"version": "[71.1600.4, )"  
			}  
		}  
	}  
}  

Changing the Xamarin Diagnostics detail level doesn't help... no additional info found.

I have installed the new JDK v.17.0.3.7-hotspot but the issue still exists.

What can I do?

Thank you,

Regards

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,295 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,277 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,150 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mattia Vicari 16 Reputation points
    2022-07-21T22:16:23.9+00:00

    I can conclude that the issue is related to proguard (also for the Debug build, even if you are not selected the code shrinker).
    In the files of the Android project, I have left the custom proguard file with the action ProguardConfiguration. In the Android Options panel, the code shrinker was unselected (empty).
    Removing the proguard file and set the code shrinker to r8 (with d8 as Dex compiler), the build has done successfully.
    The same result for the release build.

    I hope that this info could help someone else also.

    Thank you @Leon Lu (Shanghai Wicresoft Co,.Ltd.) for your support.