Итак, я сейчас пытаюсь понять, как работать с кодом, специфичным для платформы.iOS работает просто отлично.Но Android вызывает у меня проблемы, и я не знаю, как это исправить.
При запуске того же кода на эмуляторе iOS мой код работает, но при запуске того же кода на эмуляторе Android выдает ошибку «Ошибка синтаксического анализа XML: незащищенный токен (APT0000)».Кто-нибудь знает, почему это происходит и как это исправить?
xaml:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="BookCodeSL.PlatInfoSap1">
<StackLayout Padding="20">
<StackLayout VerticalOptions="CenterAndExpand">
<Label Text="Device Model:"/>
<ContentView Padding="50,0,0,0">
<Label x:Name="modelLabel"
FontSize="Large"
FontAttributes="Bold"/>
</ContentView>
</StackLayout>
<StackLayout VerticalOptions="CenterAndExpand">
<Label Text="Operating System Version:"/>
<ContentView Padding="50,0,0,0">
<Label x:Name="versionLabel"
FontSize="Large"
FontAttributes="Bold"/>
</ContentView>
</StackLayout>
</StackLayout>
</ContentPage>
cs:
//...
#elif __ANDROID__
using Android.OS;
//...
public partial class PlatInfoSap1 : ContentPage
{
public PlatInfoSap1()
{
InitializeComponent();
#if __IOS__
UIDevice device = new UIDevice();
modelLabel.Text = device.Model.ToString();
versionLabel.Text = String.Format("{0} {1}", device.SystemName, device.SystemVersion);
#elif __ANDROID__
modelLabel.Text = String.Format("{0} {1}", Build.Manufacturer, Build.Model);
versionLabel.Text = Build.VERSION.Release.ToString();
#endif
}
}
edit
Ошибка может быть найдена в
abc_primary_text_disable_only_material_light.xml
это код к нему:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND