Bug 56207 - App will deserialize an XML file when Linking set to None, but not when Linking set to Sdk Assemblies Only
Summary: App will deserialize an XML file when Linking set to None, but not when Linki...
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Linker ()
Version: 7.3 (15.2)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2017-05-10 22:25 UTC by Ammar Mheir
Modified: 2017-05-10 22:26 UTC (History)
1 user (show)

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


Attachments
Test Case (25.45 KB, application/x-zip-compressed)
2017-05-10 22:25 UTC, Ammar Mheir
Details


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 for Bug 56207 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Ammar Mheir 2017-05-10 22:25:20 UTC
Created attachment 22074 [details]
Test Case

##Overview

Point and Size types from XML files will not deserialize successfully when Linking is set to "SDK Assemblies Only". When the Linker is set to "SDK Assemblies Only" Mono.Android is linked out (reducing the overall output size) however causing the application to crash with an error:

java.lang.IllegalArgumentException: width and height must be > 0

Disabling the linker will resolve this issue, however the application size climbs up to ~30mb compared to ~7mb when the linker is enabled. 


##Expected behavior

The application will build and run successfully when the Linker is set to Link SDK Assemblies and successfully reserialize the XML file containing the System.Drawing.Size Size value and a System.Drawing.Point Location value. 


##Actual Behavior

The application will build successfully however will crash when running on either a Android emulator of physical device with the following error message:

> Unhandled Exception:
> Java.Lang.Exception: width and height must be > 0
>   --- End of managed Java.Lang.Exception stack trace ---
> java.lang.IllegalArgumentException: width and height must be > 0
> 	at android.graphics.Bitmap.createBitmap(Bitmap.java:829)
> 	at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
> 	at android.graphics.Bitmap.createBitmap(Bitmap.java:739)
> 	at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:615)
> 	at md589b15ac596100f9bed06834473022d52.MainActivity.n_onCreate(Native Method)
> 	at md589b15ac596100f9bed06834473022d52.MainActivity.onCreate(MainActivity.java:29)
> 	at android.app.Activity.performCreate(Activity.java:6237)
> 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
> 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
> 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
> 	at android.app.ActivityThread.-wrap11(ActivityThread.java)
> 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
> 	at android.os.Handler.dispatchMessage(Handler.java:102)
> 	at android.os.Looper.loop(Looper.java:148)
> 	at android.app.ActivityThread.main(ActivityThread.java:5417)
> 	at java.lang.reflect.Method.invoke(Native Method)
> 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
> 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)


##Steps to replicate

1). Download attached solution
2). Set linker to "None" -> Build solution
3). Deploy to Android device / emulator

Notice how the Xamarin logo and text appears successfully on the screen

4). Stop debugging then set the Linker Setting to "Link SDK Assemblies Only"
5). Rebuild solution -> deploy

Observed is the crash once the app tries to display that same screen.


##Version Information

Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Enterprise

Xamarin   4.5.0.443 (c871575)
Xamarin.Android   7.3.0.13 (448f54f)


##Additional information

I've attempted to use Custom Linker settings to skip linking various namespaces from within the Mono.Android assembly however none seemed to have worked. 

System.Xml.Serialization
System.Drawing
Android.Graphics

and more that I can't remember at the moment since I've tried a lot of namespaces to skip in the custom linker xml file added to the project. 

Additionally, there is a discussion about this very same issue at the following Stackoverflow post:

http://stackoverflow.com/questions/43257484/xamarin-android-app-will-not-deserialize-size-and-point-when-linking-is-none
Comment 1 Ammar Mheir 2017-05-10 22:26:31 UTC
Setting to confirmed as I and the user who submitted issue on Stackoverflow were able to successfully replicate.