-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dev/grendel/enable-marshal-methods
* 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
Showing
20 changed files
with
360 additions
and
52 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
Documentation/docs-mobile/getting-started/installation/dependencies.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Binary file added
BIN
+522 KB
...ation/docs-mobile/getting-started/installation/images/vs-install-installing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+593 KB
...le/getting-started/installation/images/vs-install-select-android-components.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+807 KB
...tion/docs-mobile/getting-started/installation/images/vs-install-select-maui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+692 KB
Documentation/docs-mobile/getting-started/installation/images/vs-new-project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.67 MB
...cs-mobile/getting-started/installation/images/vs-select-android-application.png
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
14
Documentation/docs-mobile/getting-started/installation/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
54 changes: 54 additions & 0 deletions
54
Documentation/docs-mobile/getting-started/installation/net-android.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)." |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.