Bug 16868 - Getting System.NullReferenceException' when changing orientation of device.
Summary: Getting System.NullReferenceException' when changing orientation of device.
Status: VERIFIED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: Samples ()
Version: 4.12.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Peter Collins
URL:
Depends on:
Blocks:
 
Reported: 2013-12-18 03:01 UTC by narayanp
Modified: 2014-01-14 05:12 UTC (History)
3 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:
VERIFIED INVALID

Description narayanp 2013-12-18 03:01:09 UTC

    
Comment 1 narayanp 2013-12-18 03:20:20 UTC
Steps to reproduce:
1. Open X.S
2. Create android template application.
3. Open Resources->Layout->Main.axml file
4. Observe that default button "Hello World, Click Me!" appears in portrait mode.
5. Now click 'Alternative Layout'->New Version select Screen Orientation as Landscape.
6. Observe that default button "Hello World, Click Me!" appears in landscape mode as well.
7. Delete this button and add another one.
8. Debug or run the sample.
9. Change Device/Emulator Orientation.

Actual Result: Application get crashed after changing Orientation. If user does not delete default button "Hello World, Click Me!" from landscape mode and then change Orientation after deploying application then it is working fine.

Expected Result: User should able to change Orientation.

Supplement info:
http://screencast.com/t/9h2U3muLZXWE
Exception Details: https://gist.github.com/saurabh360/5bf41c8edd9b0f515402
Android Log: https://gist.github.com/saurabh360/281a242e951c21e59699
ADB Logcat: https://gist.github.com/saurabh360/b1d0cbd15421679f0e66

Environment details:
All Mac and Windows
X.S 4.2.2(build 2)
Mono 3.2.6
X.Android 4.11.0.210(mac)
X.Android 4.11.0.208(windows)

Regression Status: Same behavior is happening with stable X.Android 4.10.1-73
Comment 2 Mohit Kheterpal 2013-12-18 12:21:03 UTC
An update to the above issue
Correct Version of XS is 4.2.3 (build 20)

Please ignore 'XS version' of Environment details mention in bug.
Comment 3 Peter Collins 2014-01-02 15:24:18 UTC
This is not a valid bug, what you've done is create an alternate layout in the editor, but you have not properly handled that change in the main activity.

Creating a new button in landscape creates a button with id `button1`, but in the main activity, it is looking for a button with the id `myButton` (which only exists in portrait mode).

As a result the following line fails, and your button is null (which will throw an NRE when we attempt to use that button in the next line).
Button button = FindViewById<Button> (Resource.Id.myButton);
Comment 4 Akhilesh kumar 2014-01-14 05:12:10 UTC
AS per comment 3, this issue is invalid.

Hence closing this issue.