Bug 12400 - User is not able to define 'SetLayerType'.
Summary: User is not able to define 'SetLayerType'.
Status: RESOLVED UPSTREAM
Alias: None
Product: Android
Classification: Xamarin
Component: Samples ()
Version: 4.6.x
Hardware: PC Mac OS
: Low minor
Target Milestone: ---
Assignee: Peter Collins
URL:
Depends on:
Blocks:
 
Reported: 2013-05-27 04:30 UTC by narayanp
Modified: 2013-05-28 13:53 UTC (History)
5 users (show)

Tags:
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:
Status:
RESOLVED UPSTREAM

Description narayanp 2013-05-27 04:30:55 UTC
Steps to reproduce this issue:
1. Open SvgAndroid sample application.
2. Debug or run the application on Jallybean device.
3. Observe that only white screen appears.
4. Open SampleActivity.cs file.
5. Paste below code in this file.
public static void setHardwareAccelerated(View view, Boolean enabled){
			if(Build.VERSION.SdkInt >= Build.VERSION_CODES.Froyo){
				if(enabled)
					view.setLayerType(view.LAYER_TYPE_HARDWARE, null);
				else view.setLayerType(view.LAYER_TYPE_SOFTWARE, null);
			}
		}
6. Build the sample.

Actual result: We are getting error "Android.Views.view does not contain a definition for 'SetLayerType'. We have followed links: https://github.com/pents90/svg-android/issues/7
http://code.google.com/p/svg-android/issues/detail?id=37

Expected Result: User should able to build the application.

Supplement info:
Build Output: https://gist.github.com/atin360/ba36dcef65142362b5e8
http://screencast.com/t/GwwQokWG

Environment details:
X.S 4.0.7(build 3)
Mono 2.10.12
Xamarin.Android 4.6.7-4

Regression Status:
NOT A REGRESSION: This is also happening with Stable Xamarin.Android 4.6.5-3
Comment 1 Jonathan Pryor 2013-05-27 11:10:47 UTC
The code you found and used in (5) is Java, not C#, and thus is not expected to compile as-is. You will need to port it, e.g. (untested)

    public static void SetHardwareAccelerated(View view, bool enabled)
    {
        if ((int) Build.VERSION.SdkInt >= (int) Build.VERSION_CODES.Froyo) {
            if (enabled)
                view.SetLayerType (LayerType.Hardware, null);
            else
                view.SetLayerType (LayerType.Software, null);
        }
    }
Comment 2 Nischal 2013-05-28 10:10:01 UTC
I have checked this issue using this code which is mentioned in Comment#1 and now I am getting 3 build errors: https://gist.github.com/atin360/1652c9e9fccae507c37d

X.S 4.0.8(build 2)
Xamarin.Android 4.6.7-4

Hence reopening this issue.
Comment 3 narayanp 2013-05-28 10:26:57 UTC
An update to the above comment#2 

We are trying to fix Bug 10640
Comment 4 PJ 2013-05-28 11:34:29 UTC
That bug does seem to be an issue with Android. It would be ok to get a workaround working for the sample, but this is basically just a sample bug.
Comment 5 Jonathan Pryor 2013-05-28 12:11:23 UTC
@Nischal: As noted in Comment #1, the code was _untested_; it was an example of what needed to be done, not tested and compilable code.

That said, the code provided in Comment #1 compiles for me without error. I suspect your code is missing an `(int)` cast somewhere.

Alternatively, try this version, which does compile for me:

	public static void SetHardwareAccelerated(View view, bool enabled)
	{
		if (Build.VERSION.SdkInt < BuildVersionCodes.Froyo)
			return;
		view.SetLayerType (enabled ? LayerType.Hardware : LayerType.Software, null);
	}
Comment 6 Peter Collins 2013-05-28 13:39:58 UTC
The build error reported in this bug: "Android.Views.view does not contain a definition for 'SetLayerType'." is due to the target framework being set below 11. This will not compile unless the sample's target framework is set to API 11+, as this is when the SetLayerType method was implemented. 

As far as the white screen issue, I am unable to reproduce this on a 4.1.2 and 4.2.2 device on our current stables (X.A. 4.6.7), on both debug and release.

What device (model and version) was tested?
Comment 7 Peter Collins 2013-05-28 13:53:17 UTC
The work-arounds suggested in this bug (mainly comment 5) will require the samples Target API to be set to 11+. As we have been unable to reproduce the white screen bug on a number of JellyBean devices, and the root issue does not seem to be Xamarin specific, I am resolving this. If we receive enough complaints or pressure about this issue in the future we should reopen and reassess.