Bug 60324 - GetJavaPlatformJar needs better error handling instead of ArgumentNullException
Summary: GetJavaPlatformJar needs better error handling instead of ArgumentNullException
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-10-23 15:00 UTC by Alexander Köplinger [MSFT]
Modified: 2017-11-13 10:27 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Alexander Köplinger [MSFT] 2017-10-23 15:00:23 UTC
Hit this locally in a build:

> 	Task "GetJavaPlatformJar"
> 		Using task GetJavaPlatformJar from Xamarin.Android.Tasks.GetJavaPlatformJar, Xamarin.Android.Build.Tasks, Version=, Culture=neutral, PublicKeyToken=null
> 		GetJavaPlatformJar Task
> 		  AndroidSdkDirectory: /Users/alexander/Library/Developer/Xamarin/android-sdk-macosx
> 		  AndroidSdkPlatform: 18
> 		  AndroidManifest: /Users/alexander/dev/xamarin-android/bin/TestDebug/temp/BuildMultiDexApplicationFalsev7.1/Properties/AndroidManifest.xml
> /Users/alexander/dev/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Error executing task GetJavaPlatformJar: Value cannot be null.
> Parameter name: path1
> 		Error executing task GetJavaPlatformJar: System.ArgumentNullException: Value cannot be null.
> 		Parameter name: path1
> 		  at System.IO.Path.Combine (System.String path1, System.String path2) [0x00003] in <4656b2b94f914437bce672312dd9e44b>:0 
> 		  at Xamarin.Android.Tasks.GetJavaPlatformJar.Execute () [0x00188] in <3fa51b5c8b554c02b4c7f549bcabde77>:0 
> 		  at Microsoft.Build.BuildEngine.TaskEngine.Execute () [0x00000] in <cbad9a49d2cc4e87ad2241615dd4666c>:0 
> 		  at Microsoft.Build.BuildEngine.BuildTask.Execute () [0x0008d] in <cbad9a49d2cc4e87ad2241615dd4666c>:0 
> 		Done building target "_ValidateAndroidPackageProperties" in project "/Users/alexander/dev/xamarin-android/bin/TestDebug/temp/BuildMultiDexApplicationFalsev7.1/UnnamedProject.csproj" ("/Users/alexander/dev/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets"); "Build" depends on it.
> 		Done building target "Build" in project "/Users/alexander/dev/xamarin-android/bin/TestDebug/temp/BuildMultiDexApplicationFalsev7.1/UnnamedProject.csproj" ("/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/mono/xbuild/14.0/bin/Microsoft.Common.targets"); "SignAndroidPackage" depends on it.
> 		Done building target "SignAndroidPackage" in project "/Users/alexander/dev/xamarin-android/bin/TestDebug/temp/BuildMultiDexApplicationFalsev7.1/UnnamedProject.csproj" ("/Users/alexander/dev/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets").

The TryGetPlatformDirectoryFromApiLevel() in https://github.com/xamarin/xamarin-android/blob/6c4d912550798a58b1a63b3c528c1d62a530ce15/src/Xamarin.Android.Build.Tasks/Tasks/GetJavaPlatformJar.cs#L72 can return null. This should be checked and handled gracefully.
Comment 1 dean.ellis 2017-10-25 12:45:20 UTC
PR is up https://github.com/xamarin/xamarin-android/pull/976
Comment 2 Alexander Köplinger [MSFT] 2017-11-12 19:26:36 UTC
The PR was merged, I guess we can close this?
Comment 3 dean.ellis 2017-11-13 10:27:42 UTC
Fixed in Xamarin-android/master/7f45a6d