Bug 59713 - Loading xaml file in designer fails
Summary: Loading xaml file in designer fails
Status: RESOLVED DUPLICATE of bug 56272
Alias: None
Product: Android
Classification: Xamarin
Component: Designer ()
Version: 7.4 (15.3)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jérémie Laval
URL:
Depends on:
Blocks:
 
Reported: 2017-09-25 02:22 UTC by ebugden
Modified: 2017-09-25 18:24 UTC (History)
2 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 DUPLICATE of bug 56272

Description ebugden 2017-09-25 02:22:19 UTC
The following error occurs when loading the XAML file:

mono.android.DesignerException: java.lang.NullPointerException
	at mono.android.DesignerException.fromThrowable(DesignerException.java:46)
	at mono.android.DesignerSession.checkRenderResultForError(DesignerSession.java:187)
	at mono.android.DesignerSession.load(DesignerSession.java:239)
	at mono.android.DesignerSession.processMessage(DesignerSession.java:704)
	at mono.android.MessageListener.executeMessage(MessageListener.java:88)
	at mono.android.MessageListener$Runner.run(MessageListener.java:44)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
	at android.content.res.Resources_Delegate.disposeSystem(Resources_Delegate.java:85)
	at com.android.layoutlib.bridge.android.BridgeContext.disposeResources(BridgeContext.java:264)
	at com.android.layoutlib.bridge.impl.RenderAction.tearDown(RenderAction.java:257)
	at com.android.layoutlib.bridge.impl.RenderAction.release(RenderAction.java:220)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:438)
	at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
	at mono.android.DesignerSession.load(DesignerSession.java:233)
	... 4 more


The contents of the XAML file are as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:p2="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minWidth="25px"
    android:minHeight="25px"
    p2:gridSpec="0|8|#0093eeff|K:#ee8700ff:16,l:72,l:16,r|S:#83ee00ff:16,0,l:16,56,l:16,0,r"
    android:id="@+id/linearLayout1">
    <TextView
        android:text="Header"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView1" />
    <Button
        android:text="Update Device"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btnUpdate"
        android:clickable="true"
        android:enabled="true"
        android:onClick="onClickUpdate" />
</LinearLayout>
Comment 1 Jon Douglas [MSFT] 2017-09-25 15:02:31 UTC
Just to be sure here, it looks like you have axml code here instead of XAML. Did you mean AXML(XML)? Can you please add your full version information from Help -> About Visual Studio and include your JDK version? If you are not currently using a x64 bit version of the JDK 1.8, please download it, and uninstall your other versions. Once you've done that, ensure this JDK is on your JDK path in your Tools->Options->Xamarin->Android settings.

Thank you!
Comment 2 ebugden 2017-09-25 17:30:54 UTC
Jon,

Sorry, I got a little dyslexic typing. Changed the X and A around. It is definitely the axml file that fails to load.

The following is the Installed Products from Visual Studio:
Microsoft Visual Studio Professional 2017 
Version 15.3.5
VisualStudio.15.Release/15.3.5+26730.16
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Professional

Visual Basic 2017   00370-10000-35480-AA007
Microsoft Visual Basic 2017

Visual C# 2017   00370-10000-35480-AA007
Microsoft Visual C# 2017

Visual C++ 2017   00370-10000-35480-AA007
Microsoft Visual C++ 2017

Visual F# 4.1   00370-10000-35480-AA007
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.8.00712.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30726.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Template Engine 2017   15.0.30726.0
ASP.NET Template Engine 2017

ASP.NET Web Frameworks and Tools 2012   4.0.20601.0
For additional information, visit https://www.asp.net/

ASP.NET Web Frameworks and Tools 2017   5.2.50601.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30728.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.3.0000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Data Lake Tools for Visual Studio   2.3.0000.0
Microsoft Azure Data Lake Tools for Visual Studio

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Devart dotConnect for PostgreSQL   7.9.931.0
Devart dotConnect for PostgreSQL
Copyright 2002 - 2017 Devart. All rights reserved.
Web: www.devart.com/dotconnect/postgresql
Support: support@devart.com

Devart Entity Developer   6.1.284.0
Devart Entity Developer
Copyright © 2008-2017 Devart. All rights reserved.
Web: www.devart.com/entitydeveloper 
Support: support@devart.com

Dotfuscator Community Edition   5.30.0.5167-c98e2f8
PreEmptive Protection - Dotfuscator CE

GitHub.VisualStudio   2.3.3.38
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node   2.2.8000.0
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.3.0000.0
Language service for Hive query

Microsoft Azure Stream Analytics Language Service   2.3.0000.0
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50719.1

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.6.8-pre (ec7034f)
Support for debugging Mono processes with Visual Studio.

MZ-Tools   8.0.0.169
MZ-Tools productivity plug-in for Visual Studio. For more information, visit http://www.mztools.com

Node.js Tools   1.0.0.0
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager   4.3.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools   15.1.61707.200
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   2.3.4.0
TypeScript tools for Visual Studio

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Apache Cordova   15.120.6728.1
Visual Studio Tools for Apache Cordova

Visual Studio Tools for Universal Windows Apps   15.0.26730.08
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin   4.7.9.45 (bd7e3753c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.4.5.1 (fb018c5)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.0.0.0 (152b654)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

The Java version that I am using is found in c:\Program Files\Java\jdk1.8.0_141. I do have a Java version 1.7.x loaded for a separate application that I must leave on the system.

I do have a Java 8, Update 141 (64 bit) installed.
Comment 3 Jon Douglas [MSFT] 2017-09-25 17:43:00 UTC
Interestingly, I am not able to reproduce this in either Android Studio (2.3.3) or Visual Studio (15.3 or 15.4)

Testing on Visual Studio 15.3 with the same exact version information as reported in this bug, I am unable to reproduce this issue. The layout successfully displays.

Thus I believe you are running into the following issue:

https://bugzilla.xamarin.com/show_bug.cgi?id=56272

Can you confirm that you are setting your Target Framework to an API version >= 21?

Secondly, when in the designer can you try to switch the "Version" drop down to be >= 21?

It seems this issue might be directly related to having an old version set in the designer as to what it needs to display. If you can confirm this, you can workaround by setting these items higher than KitKat (API 19).
Comment 4 ebugden 2017-09-25 18:19:22 UTC
I am using API version 19. I need to be able to run my application on older phones and KitKat is the oldest version that will support my functionality.

At one point, this function did work as we designed the form using API 19. 

I have run a test of my application with the minimum and target version set to 25, and I still get the error.
Comment 5 Jon Douglas [MSFT] 2017-09-25 18:24:33 UTC
(In reply to ebugden from comment #4)
> I am using API version 19. I need to be able to run my application on older
> phones and KitKat is the oldest version that will support my functionality.
> 
> At one point, this function did work as we designed the form using API 19. 
> 
> I have run a test of my application with the minimum and target version set
> to 25, and I still get the error.

I understand, however for the current workaround it requires the "Version" drop down in the Designer Surface to be >= API 19. This will not affect your application in anyway deploying to API 19 as long as your minSdkVersion is 19. You can read more about this here:

https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd

You can additionally use the Preview build which has a fix for this.

*** This bug has been marked as a duplicate of bug 56272 ***