Skip to content

Commit ce5bbd0

Browse files
authored
[docs] Add "Getting Started" docs (#8934)
Context: 5915027 I forgot to add `Documentation/docs-mobile/getting-started` as part of commit 5915027! Oops. Add the overlooked documentation.
1 parent 50419e1 commit ce5bbd0

File tree

9 files changed

+262
-0
lines changed

9 files changed

+262
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: "Install .NET for Android dependencies"
3+
description: "Learn how to install .NET for Android dependencies so you can create native Android applications."
4+
ms.date: 11/01/2023
5+
---
6+
# Install .NET for Android dependencies
7+
8+
In order to build .NET for Android applications you need to install the Android SDK and the Java SDK.
9+
10+
## Using "InstallAndroidDependencies" target
11+
12+
The easiest way to install the required dependencies for your Android application is to run the
13+
[`InstallAndroidDependencies`](../../building-apps/build-targets.md#installandroiddependencies)
14+
MSBuild target.
15+
16+
This target will examine your application project and install the exact components which are needed.
17+
If you update your project to target a new Android API you will need to run this target again
18+
to make sure you get the required components.
19+
20+
For example if you are upgrading your project to target API 34 from API 32, you will only have
21+
API 32 installed. Running the `InstallAndroidDependencies` target will install API 34 for you.
22+
23+
If you do not have the Android SDK installed at all, this target can also handle installing the SDK
24+
on a clean machine. You can change the destination of the installation by setting the
25+
`AndroidSdkDirectory` MSBuild property. It will also install the Java SDK if the `JavaSdkDirectory`
26+
MSBuild property is provided.
27+
28+
```dotnetcli
29+
dotnet build -t:InstallAndroidDependencies -f net8.0-android -p:AndroidSdkDirectory=c:\work\android-sdk -p:JavaSdkDirectory=c:\work\jdk -p:AcceptAndroidSdkLicenses=True
30+
```
31+
32+
Here are all the arguments which the target will use when installing the dependencies:
33+
34+
* `-p:AndroidSdkDirectory="<PATH>"` installs or updates Android dependencies to the specified path.
35+
*Note*: You must use an absolute path; Unix developers should not use tilde (`~`), as it is
36+
not expanded when used *within* a command-line argument.
37+
38+
* `-p:JavaSdkDirectory="<PATH>"` installs Java to the specified path.
39+
*Note*: You must use an absolute path; Unix developers should not use tilde (`~`), as it is
40+
not expanded when used *within* a command-line argument.
41+
42+
* `-p:AcceptAndroidSDKLicenses=True` accepts the necessary Android licenses for development.
43+
44+
> [!NOTE]
45+
> To make development easier try to avoid using paths which contain spaces or non-ASCII characters.
46+
47+
## Install the Android SDK manually
48+
49+
You might find it necessary to install the Android SDK manually:
50+
51+
1. Go to [Android Studio download](https://developer.android.com/studio#download).
52+
Scroll down to the "Command Line Tools only" section and download the zip file for your operating system.
53+
54+
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`.
55+
56+
3. Extract the files from the zip file into this directory. You should end up with a folder structure like
57+
`android-sdk\cmdline-tools`
58+
59+
4. Open a terminal or Command Prompt.
60+
61+
5. Navigate to the `android-sdk\cmdline-tools\bin` directory within the directory you created.
62+
63+
6. Run the `sdkmanager` command to install the desired components.
64+
65+
For example, to install the latest platform and platform tools, use:
66+
67+
```console
68+
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
69+
```
70+
71+
Note that double-quotes should be used liberally to enclose the semicolon `;`, which is part of the component names.
72+
73+
You will be prompted to accept the license, after which the Android SDK will install.
74+
75+
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.
76+
77+
```console
78+
sdkmanager --list
79+
```
80+
81+
The following component types are useful to know:
82+
83+
* `platforms;android-XX`: Installs the platform `android-XX` into the sdk.
84+
Replace *XX* with the API Level of your chosen platform.
85+
For example `platforms;android-30` will install Android API 30, while
86+
`platforms;android-21` will install Android API 21.
87+
88+
* `system-images;android-XX;default;x86_64`: Installs an emulator image for
89+
the specific API level. The `x86_64` can be swapped out for different ABIs
90+
such as `x86`, `arm64-v8a`, and `x86_64`. These reflect the ABI of the image
91+
being installed. This can be useful if you have issues on specific ABI's.
92+
93+
It is also good practice to set the `ANDROID_HOME` environment variable, as this
94+
allows you to use certain tooling from the command line.
95+
96+
## Install Microsoft JDK manually
97+
98+
In order to build .NET for Android applications or libraries you need to have a version of the Java Development Kit installed.
99+
We recommend you use the Microsoft Open JDK, this has been tested against our .NET for Android builds:
100+
101+
1. Download [Microsoft OpenJDK 11](/java/openjdk/download#openjdk-11).
102+
103+
2. Depending on your platform run the appropriate installer.
104+
105+
3. It is also good practice to set the `JAVA_HOME` environment variable.
106+
This will allow you to use the JDK from the Command Prompt or Terminal.
Loading
Loading
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Installation
3+
description: Install .NET for Android
4+
ms.date: 04/17/2024
5+
---
6+
7+
# Installation overview
8+
9+
.NET for Android allows writing applications for the
10+
[Android Operating System](https://developer.android.com) using .NET.
11+
12+
In order to use .NET for Android, you must first
13+
[install .NET for Android](net-android.md), and then you need to
14+
[install dependencies such as the Android SDK](dependencies.md).
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: "Install .NET for Android"
3+
description: "Learn how to install .NET for Android so you can create native android applications."
4+
ms.date: 11/01/2023
5+
---
6+
# Install .NET for Android
7+
8+
Developing native, .NET for Android apps requires .NET 6 or higher. Various IDE's can be used, however
9+
we recommend Visual Studio 2022 17.3 or greater, or Visual Studio Code.
10+
11+
<!-- markdownlint-disable MD025 -->
12+
## [Install via the Command Prompt or Terminal](#tab/commandline)
13+
<!-- markdownlint-enable MD025 -->
14+
15+
1. Install the [latest .NET](https://dotnet.microsoft.com/download) for your particular platform
16+
and follow its [installation instructions](/dotnet/core/install).
17+
18+
2. From a Command Prompt or Terminal run:
19+
20+
```dotnetcli
21+
dotnet workload install android
22+
```
23+
24+
3. In order to build Android applications you also need to install the
25+
[Android SDK and other dependencies](dependencies.md#using-installandroiddependencies-target).
26+
27+
28+
<!-- markdownlint-disable MD025 -->
29+
## [Install via Visual Studio](#tab/visualstudio)
30+
<!-- markdownlint-enable MD025 -->
31+
32+
1. Install the [latest Visual Studio](https://visualstudio.microsoft.com/downloads/).
33+
34+
2. Select the .NET Multi Platform App UI Development workload and any other workloads you want.
35+
36+
![Select .Net Multi Platform App UI WorkLoad](images/vs-install-select-maui.png)
37+
38+
3. Or select the .NET for Android SDK component from the Individual Components tab.
39+
40+
![Select .NET for Android SDK Component](images/vs-install-select-android-components.png)
41+
42+
4. Let the installer run, it may take a while depending on your Internet Connection.
43+
44+
![The Running Installer](images/vs-install-installing.png)
45+
46+
5. Once installed you can run Visual Studio.
47+
48+
You will be presented with the start up screen. Select New Project:
49+
50+
![Select the New Project Menu](images/vs-new-project.png)
51+
52+
6. Look through the templates to find the Android Application Template
53+
54+
![Select the Android Application Template](images/vs-select-android-application.png)

Documentation/docs-mobile/index.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
### YamlMime:Hub
2+
3+
#root section (Required)
4+
title: .NET for Android documentation
5+
summary: >
6+
.NET for Android allows you to write Android apps using .NET languages.
7+
brand: dotnet
8+
9+
metadata:
10+
title: .NET for Android
11+
description: The .NET for Android guide has everything you need to learn .NET on the Android platform.
12+
ms.service: dotnet-android
13+
ms.topic: hub-page
14+
author: jonpryor
15+
ms.author: jopryo
16+
ms.date: 04/18/2024
17+
18+
# highlightedContent section (Optional; Remove if not applicable.)
19+
# Maximum of 8 items
20+
highlightedContent:
21+
# itemType: architecture | concept | deploy | download | get-started | how-to-guide | training | overview | quickstart | reference | sample | tutorial | video | whats-new
22+
items:
23+
# Card
24+
- title: Install .NET for Android
25+
itemType: get-started
26+
url: ./getting-started/installation/index.md
27+
28+
conceptualContent:
29+
# itemType: reference
30+
# Supports up to 3 subsections
31+
sections:
32+
- title: .NET for Android reference
33+
items:
34+
# Card
35+
- title: Building Android Apps
36+
summary: Building Android Apps
37+
links:
38+
- url: ./building-apps/build-process.md
39+
itemType: reference
40+
text: Build Process
41+
- url: ./building-apps/build-targets.md
42+
itemType: reference
43+
text: Build Targets
44+
- url: ./building-apps/build-properties.md
45+
itemType: reference
46+
text: Build Properties
47+
- url: ./building-apps/build-items.md
48+
itemType: reference
49+
text: Build Items
50+
# Card
51+
- title: Features
52+
summary: .NET for Android Features
53+
links:
54+
- url: ./features/layout-code-behind/index.md
55+
itemType: reference
56+
text: Layout Code Behind
57+
- url: ./features/maven/android-maven-library.md
58+
itemType: reference
59+
text: "@(AndroidMavenLibrary) Build Item"
60+
# Card
61+
- title: Message reference
62+
summary: Tooling error and warning message reference.
63+
links:
64+
- url: ./messages/index.md
65+
itemType: reference
66+
text: Messages reference
67+
68+
69+
# additionalContent section (Optional; Remove if not applicable.)
70+
# Card with links style
71+
additionalContent:
72+
# Supports up to 4 subsections
73+
sections:
74+
75+
- title: API reference # < 60 chars (optional)
76+
summary: Search the .NET API documentation. # < 160 chars (optional)
77+
items:
78+
# Card
79+
- title: ".NET API reference"
80+
summary: API reference documentation for .NET
81+
url: /dotnet/api/index.md?view=net-8.0
82+
# Card
83+
- title: ".NET for Android reference"
84+
summary: Android-specific API reference
85+
url: /dotnet/api/?preserve-view=true&view=net-android-34.0
86+
87+
# footer (Optional; Remove if not applicable.)
88+
footer: "Are you interested in contributing to the .NET docs? For more information, see our [contributor guide](/contribute/dotnet/dotnet-contribute)."

0 commit comments

Comments
 (0)