Fixed building Android under both WinUI 2 and 3

This commit is contained in:
Arlo Godfrey 2022-04-13 13:14:11 -05:00
Родитель f16088f337
Коммит a990aff569
6 изменённых файлов: 19 добавлений и 12 удалений

Просмотреть файл

@ -3,6 +3,7 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove(directory.build.props))" Condition="Exists('$([MSBuild]::GetPathOfFileAbove(directory.build.props))')" />
<Import Project="$(RepositoryDirectory)\common\Labs.SampleRefs.props" />
<Import Project="$(RepositoryDirectory)\common\Labs.Head.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -30,7 +31,7 @@
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
@ -49,7 +50,7 @@
<AndroidManagedSymbols>true</AndroidManagedSymbols>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
@ -70,8 +71,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Uno.UI" Version="4.1.8" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.1.8" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.1.8" />
<PackageReference Include="Uno.UniversalImageLoader" Version="1.9.33" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />

Просмотреть файл

@ -9,7 +9,14 @@ using Android.Runtime;
using Android.Views;
using Android.Widget;
using Com.Nostra13.Universalimageloader.Core;
#if WINAPPSDK
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
#else
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;
#endif
namespace CommunityToolkit.Labs.Droid
{
@ -20,7 +27,7 @@ namespace CommunityToolkit.Labs.Droid
HardwareAccelerated = true,
Theme = "@style/AppTheme"
)]
public class Application : Windows.UI.Xaml.NativeApplication
public class Application : NativeApplication
{
public Application(IntPtr javaReference, JniHandleOwnership transfer)
: base(() => new CommunityToolkit.Labs.Shared.App(), javaReference, transfer)

Просмотреть файл

@ -4,6 +4,12 @@ using Android.OS;
using Android.Content.PM;
using Android.Views;
#if WINAPPSDK
using Microsoft.UI.Xaml;
#else
using Windows.UI.Xaml;
#endif
namespace CommunityToolkit.Labs.Droid
{
[Activity(
@ -11,7 +17,7 @@ namespace CommunityToolkit.Labs.Droid
ConfigurationChanges = global::Uno.UI.ActivityHelper.AllConfigChanges,
WindowSoftInputMode = SoftInput.AdjustPan | SoftInput.StateHidden
)]
public class MainActivity : Windows.UI.Xaml.ApplicationActivity
public class MainActivity : ApplicationActivity
{
}
}

Просмотреть файл

@ -19,8 +19,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Uno.UI.Skia.Gtk" Version="4.1.8" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.1.8" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.1.8" />
</ItemGroup>
<Import Project="$(RepositoryDirectory)\common\Labs.SampleRefs.props" />

Просмотреть файл

@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Import Project="$(RepositoryDirectory)common\Labs.TargetFrameworks.props" />
<Import Project="$(RepositoryDirectory)common\Labs.Uno.props" />
<PropertyGroup>
<OutputType Condition="'$(Configuration)'=='Release'">WinExe</OutputType>
@ -9,8 +10,6 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Uno.UI.Skia.Wpf" Version="4.1.8" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.1.8" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.1.8" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -9,8 +9,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Uno.UI.Skia.Wpf" Version="4.1.8" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.1.8" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.1.8" />
</ItemGroup>
</Project>