1

I created an empty Xamarin.Forms project on Visual Studio 2019 for Android and IOS and without adding any code and this error popped up without letting me build the project.

MSB6006: "java.exe" exited with code 2.

I have looked into this and I've tried

  • Deleting bin and obj file from Xamarin.Android and rebuild
  • Repairing Visual Studio
  • Untick the sign Apk option on Android properties
  • Checking Multi-Dex on Android properties
  • Uninstalling and installing Visual Studio 2019 again
  • Changing the sdk file path like so android-sdk path containing "space"

And I have looked into this solutions but none of them work for me

Please help because I don't know what is causing this and I have tried everything.

EDIT: After a couple of times trying to build the project this is the error that shows up:

Mono.AndroidTools.InstallFailedException: The package was not properly signed (NO_CERTIFICATES).
   en Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) en D:\a\_work\1\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:línea 338
   en Mono.AndroidTools.AndroidDevice.<>c__DisplayClass100_0.<InstallPackage>b__0(Task`1 t) en D:\a\_work\1\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:línea 803
   en System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
   en System.Threading.Tasks.Task.Execute()
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
   en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   en AndroidDeviceExtensions.<PushAndInstallPackageAsync>d__12.MoveNext() en D:\a\_work\1\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:línea 206
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
   en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   en AndroidDeviceExtensions.<PushAndInstallPackageAsync>d__12.MoveNext() en D:\a\_work\1\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:línea 223
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
   en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   en Xamarin.Android.Tasks.FastDeploy.<InstallPackage>d__101.MoveNext() en /Users/builder/azdo/_work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:línea 338
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
   en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   en Xamarin.Android.Tasks.FastDeploy.<InstallPackage>d__101.MoveNext() en /Users/builder/azdo/_work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:línea 355
--- Fin del seguimiento de la pila de la ubicación anterior donde se produjo la excepción ---
   en System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   en System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   en Xamarin.Android.Tasks.FastDeploy.<RunTaskAsync>d__96.MoveNext() en /Users/builder/azdo/_work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:línea 212           0   Compilación 
Jingmiao Xu-MSFT
  • 2,076
  • 1
  • 3
  • 10
mml
  • 111
  • 1
  • 10
  • Please check in Tools --> Options --> Xamarin --> Android Settings which JDK are you using. Mine is C:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot and it is working with no issues – CyberZeus Apr 21 '22 at 10:17
  • Try 3rd response : https://stackoverflow.com/questions/54672028/xamarin-forms-java-exe-exited-with-code-2-in-vs-2017?force_isolation=true – jdweng Apr 21 '22 at 10:19
  • @CyberZeus I had that jdk path in the beggining and didn't work so I changed it to `C:\Program Files\Java\jdk1.8.0_202` – mml Apr 21 '22 at 10:23
  • @jdweng I'm gessing I need to add those two labels `d8` and `r8` on my Android.csproj `` – mml Apr 21 '22 at 10:25
  • What Android SDK are you targeting? – CyberZeus Apr 21 '22 at 10:26
  • @CyberZeus For Android 11 – mml Apr 21 '22 at 10:32
  • Try opening the csproj file with notepad. There is a signing property that you can set to false. – jdweng Apr 21 '22 at 10:34
  • @jdweng I can't find that signing property, I've seen that solution before but I can't find it – mml Apr 21 '22 at 10:36
  • @jdweng Tried the third response and didn't work either – mml Apr 21 '22 at 10:47
  • Try this : false – jdweng Apr 21 '22 at 12:16
  • @jdweng I think it's an issue with some visual studio folder because any project that I create won't let me build – mml Apr 22 '22 at 08:20
  • Probably problem is due to how VS was installed. When you install an application you can install for just one user or all users. You probably install for one user and then tried to use with a different users. You may of installed as a user instead of an Admin. The Admin install give option to install for all users. – jdweng Apr 22 '22 at 10:38

1 Answers1

2

For me what worked was just deleting the following:

  • Android folder which contains the sdk C:\Program Files (x86)\Android
  • Eclipse Foundation folder which contains the jdk
  • Xamarin folder C:\Users\USER\AppData\Local\Xamarin

And then reinstall Visual Studio 2019.

Before it wouldn't let me build any Xamarin project even though I had tried everything people said when referring to this error.

I hope this helped someone in case of having the same issue as me.

mml
  • 111
  • 1
  • 10