Xamarin.Android.Lite

by jonathanpeppers

jonathanpeppers / Xamarin.Android.Lite

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

125 Stars 6 Forks Last release: Not found MIT License 124 Commits 2 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

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:

xml

  
    netstandard2.0
  
  
    
    
  

Remove the existing

 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:


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,

 is the way
to go:

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.