• Stars
    star
    124
  • Rank 286,386 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created about 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Prototype/proof of concept of a "lite" Xamarin.Android that only supports Xamarin.Forms

Xamarin.Android.Lite

Prototype/proof of concept of a "lite" Xamarin.Android that only supports Xamarin.Forms.

DISCLAIMER: I created this project during Microsoft's #HackWeek 2018. It is not "a real thing" or endorsed/supported by Xamarin/Microsoft. If you would like it to be "a real thing", show your support! Star this Github repo, like the YouTube video, post on social media, comment, etc.! Every bit helps!

Download Xamarin.Android.Lite on NuGet

NuGet

Xamarin.Android.Lite

Demo Video

Xamarin.Android.Lite

NOTE: in the video, I have MSBuild.exe in my PATH example on how to do this here.

The path to my MSBuild is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin

Mac users can just run msbuild and it works...

How do I use it?

The easiest way to create a new project, is to use the Xamarin.Forms project template in Visual Studio. Just check one platform, use NetStandard, and delete the platform-specific project.

NOTE: shared projects won't work (or make sense), Xamarin.Android.Lite is for NetStandard only

Edit your project file to look something like:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <EmbeddedResource Include="**\*.png" />
    <PackageReference Include="Xamarin.Android.Lite" Version="0.1.0.43-preview" />
  </ItemGroup>
</Project>

Remove the existing <PackageReference /> to Xamarin.Forms from the Xamarin.Forms project template, as Xamarin.Android.Lite is pinned to a specific version of Xamarin.Forms.

To run the app:

  • Launch the emulator, or connect an Android device via USB
  • Use the Android-specific MSBuild targets: SignAndroidPackage, Install, or Run.

Details on each target:

  • SignAndroidPackage drops an APK file in $(OutputPath)
  • Install deploys the APK to the connected device
  • Run launches the main activity on the device

So, assuming the right MSBuild.exe is in your path on Windows (Mac will "just work"):

msbuild MyApp.csproj /t:Run

This command gets you going!

Visit the MSBuild documentation for further details about MSBuild (project) properties.

How do the build times compare?

Comparing the Install target deploying to an emulator and device (Pixel 2). I deleted bin/obj and ran msbuild /t:Restore before timing each test. On the Second Install, I modified a XAML file and ran /t:Install again.

Xamarin.Android.Lite

  • Emulator / First Install - Time Elapsed 00:00:06.54
  • Emulator / Second Install - Time Elapsed 00:00:03.01
  • Device / First Install - Time Elapsed 00:00:05.60
  • Device / Second Install - Time Elapsed 00:00:02.71

Xamarin.Android "proper"

  • Emulator / First Install - Time Elapsed 00:00:49.46
  • Emulator / Second Install - Time Elapsed 00:00:06.22
  • Device / First Install - Time Elapsed 00:00:46.87
  • Device / Second Install - Time Elapsed 00:00:05.95

NOTE: I compared this times on Windows with Visual Studio 15.7.5, using the default Xamarin.Forms Master Detail project template.

What are the limitations?

Mark Seeman on an episode of .NET Rocks talked about: "constraints liberate". I don't know if he originated the idea, but that is definitely what is happening here.

  • NetStandard 2.0 projects only, Xamarin.Forms only
  • Mono.Android.dll or native APIs? Nope.
  • Android resources/assets? Nope. Use EmbeddedResource.
  • Debugging? Sadly, not yet.
  • Release builds? Not yet.

What's in the box?

Xamarin.Android.Lite is bundled with Xamarin.Forms and Xamarin.Essentials to get the best APIs available for NetStandard.

Currently using:

<PackageReference Include="Xamarin.Forms" Version="3.1.0.697729" />
<PackageReference Include="Xamarin.Essentials" Version="0.9.1-preview" />

If another library is deemed useful here, let me know--I could bundle it!

How do I use images?

As noted in the project file above, <EmbeddedResource /> is the way to go:

<EmbeddedResource Include="**\*.png" />

Then to load the image, you will need to use the following C#:

yourImage.Source = ImageSource.FromResource ("YourNameSpace.xamarin_logo.png", typeof (App));

Or better yet, make your own XAML markup extension to do this!

How do I contribute? Or build this repo?

msbuild build.proj /t:Bootstrap
msbuild build.proj

More Repositories

1

dotnes

.NET for the NES game console
C#
617
star
2

spice

Spice 🌶, a spicy cross-platform UI framework!
C#
226
star
3

Xamarin.Forms.Mocks

Library for running Xamarin.Forms inside of unit tests
C#
195
star
4

glidex

glidex.forms is a library using Glide for faster Xamarin.Forms images on Android. Find out more about Glide at https://github.com/bumptech/glide
C#
193
star
5

boots

boots is a .NET global tool for "bootstrapping" vsix & pkg files. Just "boots https://url/to/your/package"!
C#
86
star
6

Android-NativeAOT

A .NET 8, NativeAOT example on Android
C#
66
star
7

maui-profiling

Repository for building MAUI apps over time. So we can install & profile them.
C#
57
star
8

XPlatUtils

A set of helpers for cross platform apps. Right now has a ServiceContainer and Messenger implementation.
C#
37
star
9

memory-analyzers

C# code analyzers for finding memory leaks
C#
35
star
10

Mono.Profiler.Android

Support for the Mono profiler in .NET 6 Android applications
Shell
33
star
11

inclusive-code-reviews-browser

A chrome web extension for improving code reviews on Github or Azure DevOps
JavaScript
31
star
12

Xamarin.InAppPurchasing

Sample project for secure in-app purchases with Xamarin for iOS and Google Play
C#
27
star
13

XamChat

Simple chat application for iOS and Android
C#
26
star
14

UnityBuild

Example project showing automated builds with Unity3D
C#
24
star
15

lols

Performance test: LOLs per second
C#
24
star
16

HelloGlide

A simple sample using glidex.forms
C#
15
star
17

inclusive-code-reviews-ml

Machine learning for code reviews!
C#
14
star
18

Xamarin.SSLPinning

Test project to setup SSL pinning with Xamarin.iOS
C#
14
star
19

Xamarin.Forms.Benchmarks

Using BenchmarkDotNet to write some benchmarks for Xamarin.Forms concepts.
C#
11
star
20

measure-startup

C# console app to launch a process, wait for stdout, report a time
C#
8
star
21

MemoryLeaksOniOS

Testing memory leaks on iOS
C#
6
star
22

maui-scrolling-performance

Test repository for measuring scrolling performance of .NET MAUI apps on Android
C#
5
star
23

maui-workload

Prototype of a dotnet/maui "workload"
PowerShell
3
star
24

wpf-memory-leaks

Unit tests using WPF, to discover if/how it avoids memory leaks
C#
3
star
25

android-profiled-aot

This is a repo for recording .NET 6 AOT profiles.
C#
3
star
26

MyPal

A .NET MAUI sample application that uses omni-input LLMs to create "My Pal", a friendly koala that insults you based on a selfie!
C#
3
star
27

MonoGameSaveImage

Example of using Texture2D.SaveAsPng and Texture2D.SaveAsPng
C#
2
star
28

Benchmarks

Group of C# benchmarks for testing purposes
C#
2
star
29

baseline-profiles

For recording baseline profiles, see: https://developer.android.com/topic/performance/baselineprofiles
Java
2
star
30

CustomResourceDesigner

Example of making a "slimmer" Resource.designer.cs
C#
2
star
31

BenchmarkDotNet-Android

BenchmarkDotNet projects for comparing .NET 6 to Xamarin.Android
C#
2
star
32

DeleteBinObjBug

Reproducing DeleteBinObj and/or FastDev bug
Shell
2
star
33

Live.Forms.iOS

Xamarin.Forms live XAML reloading (iOS only)
C#
2
star
34

twitch-embeddinator

Demo project taking a Xamarin.Forms app and running it with Embeddinator-4000 in Android Studio
Java
2
star
35

maui-workload-pinning

This is an example of installing .NET MAUI Preview 7 and using RC1 packs
C#
2
star
36

XamarinAndroidBuildTimes

Quick repo I'll use to profile build times on different Xamarin.Android projects
PowerShell
2
star
37

Xamarin.Forms.Performance

Repo for testing performance in Xamarin.Forms on Android
C#
2
star
38

dotnet-using-task

Testing MSBuild <UsingTask/>
C#
2
star
39

Xamarin.Firebase.Messaging.Repro

Xamarin.Firebase.Messaging.Repro
C#
1
star
40

net6-finalizer-repro

Repro for: https://github.com/xamarin/xamarin-android/pull/6363#issuecomment-937379007
C#
1
star
41

Simulations

Levi's simulations
C#
1
star
42

class-lib-pack-r2r

Include ReadyToRun compiled assemblies in a NuGet/class library.
C#
1
star
43

GetRich

A mobile app that will basically make you rich if you submit it to the app store
C#
1
star
44

Embeddinator-MonoGame

Testing running MonoGame through Embeddinator
1
star
45

IntuneRepro

Trying to repro: https://github.com/msintuneappsdk/intune-app-sdk-xamarin/issues/5
C#
1
star
46

MSBuildIncrementalClean

This is a quick sample to figure out some nuances with MSBuild
PowerShell
1
star
47

MicrosoftExtensionsRepro

Trying to repro startup performance issue on Android
C#
1
star
48

gitinfotest

This is a repro for an MSBuild issue.
C#
1
star
49

maui-view-performance

Repo for measuring .NET MAUI views & page navigation
C#
1
star
50

inclusive-code-reviews-demo

Source code for my presentation "Using ML.NET and LLMs in C#"
C#
1
star