Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/enable-marshal-methods
Browse files Browse the repository at this point in the history
* main:
  Bump to xamarin/Java.Interop/main@78d5937 (#8935)
  [docs] Add "Getting Started" docs (#8934)
  [Xamarin.Android.Build.Tests] Fix ActionBarSherlock URL (#8926)
  Update README (#8913)
  Bumps to xamarin/Java.Interop/main@4e893bf (#8924)
  Bump to dotnet/installer@fa261b952d 9.0.100-preview.5.24253.16 (#8921)
  [Mono.Android] Dispose of the `RunnableImplementor` on error (#8907)
  Bump NDK to r26d (#8868)
  • Loading branch information
grendello committed May 13, 2024
2 parents 6f2371e + 6e5239b commit 8c7aa5d
Show file tree
Hide file tree
Showing 20 changed files with 360 additions and 52 deletions.
106 changes: 106 additions & 0 deletions Documentation/docs-mobile/getting-started/installation/dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
title: "Install .NET for Android dependencies"
description: "Learn how to install .NET for Android dependencies so you can create native Android applications."
ms.date: 11/01/2023
---
# Install .NET for Android dependencies

In order to build .NET for Android applications you need to install the Android SDK and the Java SDK.

## Using "InstallAndroidDependencies" target

The easiest way to install the required dependencies for your Android application is to run the
[`InstallAndroidDependencies`](../../building-apps/build-targets.md#installandroiddependencies)
MSBuild target.

This target will examine your application project and install the exact components which are needed.
If you update your project to target a new Android API you will need to run this target again
to make sure you get the required components.

For example if you are upgrading your project to target API 34 from API 32, you will only have
API 32 installed. Running the `InstallAndroidDependencies` target will install API 34 for you.

If you do not have the Android SDK installed at all, this target can also handle installing the SDK
on a clean machine. You can change the destination of the installation by setting the
`AndroidSdkDirectory` MSBuild property. It will also install the Java SDK if the `JavaSdkDirectory`
MSBuild property is provided.

```dotnetcli
dotnet build -t:InstallAndroidDependencies -f net8.0-android -p:AndroidSdkDirectory=c:\work\android-sdk -p:JavaSdkDirectory=c:\work\jdk -p:AcceptAndroidSdkLicenses=True
```

Here are all the arguments which the target will use when installing the dependencies:

* `-p:AndroidSdkDirectory="<PATH>"` installs or updates Android dependencies to the specified path.
*Note*: You must use an absolute path; Unix developers should not use tilde (`~`), as it is
not expanded when used *within* a command-line argument.

* `-p:JavaSdkDirectory="<PATH>"` installs Java to the specified path.
*Note*: You must use an absolute path; Unix developers should not use tilde (`~`), as it is
not expanded when used *within* a command-line argument.

* `-p:AcceptAndroidSDKLicenses=True` accepts the necessary Android licenses for development.

> [!NOTE]
> To make development easier try to avoid using paths which contain spaces or non-ASCII characters.
## Install the Android SDK manually

You might find it necessary to install the Android SDK manually:

1. Go to [Android Studio download](https://developer.android.com/studio#download).
Scroll down to the "Command Line Tools only" section and download the zip file for your operating system.

2. Create an `android-sdk` directory somewhere on your hard drive. To make your life easier create it near to the root of the drive. For example `c:\android-sdk`.

3. Extract the files from the zip file into this directory. You should end up with a folder structure like
`android-sdk\cmdline-tools`

4. Open a terminal or Command Prompt.

5. Navigate to the `android-sdk\cmdline-tools\bin` directory within the directory you created.

6. Run the `sdkmanager` command to install the desired components.

For example, to install the latest platform and platform tools, use:

```console
sdkmanager "platforms;android-34" "platform-tools" "build-tools;34.0.0" "emulator" "system-images;android-34;default;x86_64" "cmdline-tools;11.0" --sdk_root=c:\android-sdk
```

Note that double-quotes should be used liberally to enclose the semicolon `;`, which is part of the component names.

You will be prompted to accept the license, after which the Android SDK will install.

You can use `sdkmanager` to install additional components. You can use the `--list` argument to get a list of all the available components. You can then look through the list and find the additional components you want.

```console
sdkmanager --list
```

The following component types are useful to know:

* `platforms;android-XX`: Installs the platform `android-XX` into the sdk.
Replace *XX* with the API Level of your chosen platform.
For example `platforms;android-30` will install Android API 30, while
`platforms;android-21` will install Android API 21.

* `system-images;android-XX;default;x86_64`: Installs an emulator image for
the specific API level. The `x86_64` can be swapped out for different ABIs
such as `x86`, `arm64-v8a`, and `x86_64`. These reflect the ABI of the image
being installed. This can be useful if you have issues on specific ABI's.

It is also good practice to set the `ANDROID_HOME` environment variable, as this
allows you to use certain tooling from the command line.

## Install Microsoft JDK manually

In order to build .NET for Android applications or libraries you need to have a version of the Java Development Kit installed.
We recommend you use the Microsoft Open JDK, this has been tested against our .NET for Android builds:

1. Download [Microsoft OpenJDK 11](/java/openjdk/download#openjdk-11).

2. Depending on your platform run the appropriate installer.

3. It is also good practice to set the `JAVA_HOME` environment variable.
This will allow you to use the JDK from the Command Prompt or Terminal.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions Documentation/docs-mobile/getting-started/installation/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Installation
description: Install .NET for Android
ms.date: 04/17/2024
---

# Installation overview

.NET for Android allows writing applications for the
[Android Operating System](https://developer.android.com) using .NET.

In order to use .NET for Android, you must first
[install .NET for Android](net-android.md), and then you need to
[install dependencies such as the Android SDK](dependencies.md).
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: "Install .NET for Android"
description: "Learn how to install .NET for Android so you can create native android applications."
ms.date: 11/01/2023
---
# Install .NET for Android

Developing native, .NET for Android apps requires .NET 6 or higher. Various IDE's can be used, however
we recommend Visual Studio 2022 17.3 or greater, or Visual Studio Code.

<!-- markdownlint-disable MD025 -->
## [Install via the Command Prompt or Terminal](#tab/commandline)
<!-- markdownlint-enable MD025 -->

1. Install the [latest .NET](https://dotnet.microsoft.com/download) for your particular platform
and follow its [installation instructions](/dotnet/core/install).

2. From a Command Prompt or Terminal run:

```dotnetcli
dotnet workload install android
```
3. In order to build Android applications you also need to install the
[Android SDK and other dependencies](dependencies.md#using-installandroiddependencies-target).
<!-- markdownlint-disable MD025 -->
## [Install via Visual Studio](#tab/visualstudio)
<!-- markdownlint-enable MD025 -->
1. Install the [latest Visual Studio](https://visualstudio.microsoft.com/downloads/).
2. Select the .NET Multi Platform App UI Development workload and any other workloads you want.
![Select .Net Multi Platform App UI WorkLoad](images/vs-install-select-maui.png)
3. Or select the .NET for Android SDK component from the Individual Components tab.
![Select .NET for Android SDK Component](images/vs-install-select-android-components.png)
4. Let the installer run, it may take a while depending on your Internet Connection.
![The Running Installer](images/vs-install-installing.png)
5. Once installed you can run Visual Studio.
You will be presented with the start up screen. Select New Project:
![Select the New Project Menu](images/vs-new-project.png)
6. Look through the templates to find the Android Application Template
![Select the Android Application Template](images/vs-select-android-application.png)
88 changes: 88 additions & 0 deletions Documentation/docs-mobile/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
### YamlMime:Hub

#root section (Required)
title: .NET for Android documentation
summary: >
.NET for Android allows you to write Android apps using .NET languages.
brand: dotnet

metadata:
title: .NET for Android
description: The .NET for Android guide has everything you need to learn .NET on the Android platform.
ms.service: dotnet-android
ms.topic: hub-page
author: jonpryor
ms.author: jopryo
ms.date: 04/18/2024

# highlightedContent section (Optional; Remove if not applicable.)
# Maximum of 8 items
highlightedContent:
# itemType: architecture | concept | deploy | download | get-started | how-to-guide | training | overview | quickstart | reference | sample | tutorial | video | whats-new
items:
# Card
- title: Install .NET for Android
itemType: get-started
url: ./getting-started/installation/index.md

conceptualContent:
# itemType: reference
# Supports up to 3 subsections
sections:
- title: .NET for Android reference
items:
# Card
- title: Building Android Apps
summary: Building Android Apps
links:
- url: ./building-apps/build-process.md
itemType: reference
text: Build Process
- url: ./building-apps/build-targets.md
itemType: reference
text: Build Targets
- url: ./building-apps/build-properties.md
itemType: reference
text: Build Properties
- url: ./building-apps/build-items.md
itemType: reference
text: Build Items
# Card
- title: Features
summary: .NET for Android Features
links:
- url: ./features/layout-code-behind/index.md
itemType: reference
text: Layout Code Behind
- url: ./features/maven/android-maven-library.md
itemType: reference
text: "@(AndroidMavenLibrary) Build Item"
# Card
- title: Message reference
summary: Tooling error and warning message reference.
links:
- url: ./messages/index.md
itemType: reference
text: Messages reference


# additionalContent section (Optional; Remove if not applicable.)
# Card with links style
additionalContent:
# Supports up to 4 subsections
sections:

- title: API reference # < 60 chars (optional)
summary: Search the .NET API documentation. # < 160 chars (optional)
items:
# Card
- title: ".NET API reference"
summary: API reference documentation for .NET
url: /dotnet/api/index.md?view=net-8.0
# Card
- title: ".NET for Android reference"
summary: Android-specific API reference
url: /dotnet/api/?preserve-view=true&view=net-android-34.0

# footer (Optional; Remove if not applicable.)
footer: "Are you interested in contributing to the .NET docs? For more information, see our [contributor guide](/contribute/dotnet/dotnet-contribute)."
Binary file modified Documentation/images/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions Documentation/previous-releases.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
Xamarin.Android Previous Releases
===============

Support for Xamarin.Android ended on **May 1, 2024** as per the [Xamarin Support Policy][xamarin-support-policy].

[xamarin-support-policy]: https://dotnet.microsoft.com/en-us/platform/support/policy/xamarin

However, the released installers are still available for download.

| Platform | Link |
|-----------------|--------|
| **Commercial Xamarin.Android 13.2.2 (d17-8)** for Windows+Visual Studio 2022 | [Download][commercial-d17-8-Windows-x86_64] |
| **Commercial Xamarin.Android 13.2.2 (d17-8)** for VSMac 2022 | [Download][commercial-d17-8-macOS-x86_64] |
| **Commercial Xamarin.Android 13.2 (d17-5)** for Windows+Visual Studio 2022 | [Download][commercial-d17-5-Windows-x86_64] |
| **Commercial Xamarin.Android 13.2 (d17-5)** for macOS | [Download][commercial-d17-5-macOS-x86_64] |
| **Commercial Xamarin.Android 13.1 (d17-4)** for Windows+Visual Studio 2022 | [Download][commercial-d17-4-Windows-x86_64] |
Expand Down Expand Up @@ -74,3 +82,5 @@ Xamarin.Android Previous Releases
[commercial-d17-4-macOS-x86_64]: https://aka.ms/xamarin-android-commercial-d17-4-macos
[commercial-d17-5-Windows-x86_64]: https://aka.ms/xamarin-android-commercial-d17-5-windows
[commercial-d17-5-macOS-x86_64]: https://aka.ms/xamarin-android-commercial-d17-5-macos
[commercial-d17-8-Windows-x86_64]: https://aka.ms/xamarin-android-commercial-d17-8-windows
[commercial-d17-8-macOS-x86_64]: https://aka.ms/xamarin-android-commercial-d17-8-macos
44 changes: 19 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,47 @@
<img src="Documentation/images/banner.png" alt=".NET Android banner" height="145" >
<img src="Documentation/images/banner.png" alt=".NET for Android banner" height="145" >

.NET Android
.NET for Android
===============

.NET Android provides open-source bindings of the Android SDK and tooling for use with
.NET for Android provides open-source bindings of the Android SDK and tooling for use with
.NET managed languages such as C#. This ships as an optional [.NET workload][net-workload] for .NET 6+ that can
be updated independently from .NET in order to respond to external dependency updates like new Android
platform and tooling.

While .NET Android is an essential part of [MAUI][maui-intro], it is still fully supported to be
used independently for native Android development using .NET.

This repository is also home to the classic Xamarin.Android product.
.NET for Android is part of [.NET MAUI][maui-intro], and may also be used independently for native Android development using .NET.

[net-workload]: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-workload-install
[maui-intro]: https://learn.microsoft.com/en-us/dotnet/maui/what-is-maui

# Support

.NET Android is now part of .NET 6+ and follows the same support lifecycle as the [MAUI Support Lifecycle][maui-support-lifecycle].
.NET for Android is part of .NET MAUI, since it was introduced in May 2022 as part of .NET 6, and is currently supported as described in the [.NET MAUI Support Policy][maui-support-policy].

Support for Xamarin.Android ended on **May 1, 2024** as per the [Xamarin Support Policy][xamarin-support-policy]:

Support for classic Xamarin.Android will end on **May 1, 2024** as per the [Xamarin Support Policy][xamarin-support-policy]:
> Xamarin support ended on May 1, 2024 for all Xamarin SDKs including Xamarin.Forms. Android API 34 and Xcode 15 SDKs (iOS and iPadOS 17, macOS 14) are the final versions Xamarin targets from existing Xamarin SDKs (i.e. no new APIs are planned).
> Xamarin support will end on May 1, 2024 for all classic Xamarin SDKs. Android 13 will be the final version classic Xamarin.Android will target.
Follow the [official upgrade guidance](https://learn.microsoft.com/dotnet/maui/migration) to bring your Xamarin applications to the latest version of .NET.

[maui-support-lifecycle]: https://dotnet.microsoft.com/en-us/platform/support/policy/maui
[maui-support-policy]: https://dotnet.microsoft.com/en-us/platform/support/policy/maui
[xamarin-support-policy]: https://dotnet.microsoft.com/en-us/platform/support/policy/xamarin

# Downloads

## Current
.NET for Android ships as a workload through the `dotnet` workload system in [.NET 6+][dotnet-download].

.NET Android ships as a workload through the `dotnet` workload system in [.NET 6+][dotnet-download]. See
the [workload documentation][workload-documentation] for installation commands.
In its simplest form, .NET for Android can be installed by running:

[dotnet-download]: https://dotnet.microsoft.com/en-us/download
[workload-documentation]: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-workload-install
```
dotnet workload install android
```

Classic Xamarin.Android installers are available here:
See the [.NET workload documentation][workload-documentation] for additional installation commands and options.

| Platform | Link |
|-----------------|--------|
| **Commercial Xamarin.Android 13.2.2 (d17-8)** for Windows+Visual Studio 2022 | [Download][commercial-d17-8-Windows-x86_64] |
| **Commercial Xamarin.Android 13.2.2 (d17-8)** for VSMac 2022 | [Download][commercial-d17-8-macOS-x86_64] |

[Previous Releases](Documentation/previous-releases.md) are also available for download.
[dotnet-download]: https://dotnet.microsoft.com/en-us/download
[workload-documentation]: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-workload-install

[commercial-d17-8-Windows-x86_64]: https://aka.ms/xamarin-android-commercial-d17-8-windows
[commercial-d17-8-macOS-x86_64]: https://aka.ms/xamarin-android-commercial-d17-8-macos
While no longer supported, Classic Xamarin.Android installers are still available [here](Documentation/previous-releases.md).

# Contributing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Xamarin.Android.Prepare
{
class BuildAndroidPlatforms
{
public const string AndroidNdkVersion = "26c";
public const string AndroidNdkPkgRevision = "26.2.11394342";
public const string AndroidNdkVersion = "26d";
public const string AndroidNdkPkgRevision = "26.3.11579264";
public const int NdkMinimumAPI = 21;
public const int NdkMinimumAPILegacy32 = 21;

Expand Down
Loading

0 comments on commit 8c7aa5d

Please sign in to comment.