GeofencePlugin
GeofencePlugin copied to clipboard
Xamarin Android error MSB6006: "java.exe" exited with code 1
After adding the Geofence plugin 1.8.11 to my project I started getting the error "java.exe" exited with code 1 for the Xamarin Android project when trying to build. I remove it and then it builds and runs in the emulator just fine. I am using Visual Studio 2022 Preview 17.2.0 Preview 3.0, and building for Android 12.0 - API 31. I have the latest version of Java installed (18). I tried compiling in Visual Studio 2019, which succeeds - but when trying to debug in the Emulator I get the following error (including stack trace). I don't care which version of Visual Studio I use, I just want to be able to get it to work in at least one of them. And no my package name does not start with a capital letter. Also in VS 2019 to fix the issue below, I tried adding Exported=true in the Activity annotation but got the following error System.InvalidOperationException: Duplicate attribute - which from what I've read online is a bug in VS 2019 and can only find a fix for it in VS 2022.
Severity Code Description Project File Line Suppression State Error ADB0010: Mono.AndroidTools.InstallFailedException: Unexpected install output: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl1873278123.tmp/base.apk (at Binary XML file line #56): crc64c554f6b6abc76285.GeofenceBootReceiver: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in D:\a_work\1\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 350
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass100_0.<InstallPackage>b__0(Task1 t) in D:\a\_work\1\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 803 at System.Threading.Tasks.ContinuationTaskFromResultTask
1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AndroidDeviceExtensions.<PushAndInstallPackageAsync>d__12.MoveNext() in D:\a_work\1\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 206
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at AndroidDeviceExtensions.<PushAndInstallPackageAsync>d__12.MoveNext() in D:\a_work\1\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 223
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.Android.Tasks.FastDeploy.<InstallPackage>d__101.MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 338
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Xamarin.Android.Tasks.FastDeploy.<InstallPackage>d__101.MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 355
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Xamarin.Android.Tasks.FastDeploy.<RunTaskAsync>d__96.MoveNext() in /Users/builder/azdo/_work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 212 0
I just encountered this issue too, after bumping my target version up. The problem is services and receivers need to have "exported" set explicitly now, and I can't figure out a way to make that modification myself, I think it needs to be fixed in this project.
I'm seeing this too. The issue lies with the GeoFenceBootReceiver.
It uses the BOOT_COMPLETED intent-filter, so needs [Service(Exported = true)] attribute added to the class.
There's no manual way to update the android manifest to do this so must be done in this package.