Skip to content

Commit 23fde10

Browse files
committed
Merge branch 'main' into dev/grendel/native-tracing
* main: It's ".NET for Android", not ".NET Android" (#8933) Bump to xamarin/Java.Interop/main@78d5937 (#8935) [docs] Add "Getting Started" docs (#8934) [Xamarin.Android.Build.Tests] Fix ActionBarSherlock URL (#8926)
2 parents 8f75b0c + 2b6fcfc commit 23fde10

File tree

223 files changed

+894
-651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+894
-651
lines changed

.gdn/tsaoptions-v2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"codebaseName": "xamarin.android_main",
2+
"codebaseName": "dotnet.android_main",
33
"notificationAliases": [
44
"dotnet-android-eng@microsoft.com"
55
],

.vscode/tasks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "Build All Xamarin.Android",
7+
"label": "Build All .NET for Android",
88
"type": "shell",
99
"windows":{ "command": ".\\build.cmd ${input:buildtype}"},
1010
"linux":{"command": "./build.sh ${input:buildtype}"},
@@ -231,4 +231,4 @@
231231
]
232232
},
233233
]
234-
}
234+
}

Documentation/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# Getting Started
44

5-
* [Installing the Xamarin.Android SDK](https://developer.xamarin.com/guides/android/getting_started/installation/)
6-
* [Xamarin.Android Documentation](https://developer.xamarin.com/guides/android/)
7-
* [Xamarin.Android API Documentation](https://developer.xamarin.com/api/root/MonoAndroid-lib/)
5+
* [Installing the .NET for Android SDK](https://developer.xamarin.com/guides/android/getting_started/installation/)
6+
* [.NET for Android Documentation](https://learn.microsoft.com/dotnet/android/)
7+
* [.NET for Android API Documentation](https://learn.microsoft.com/en-us/dotnet/api/?preserve-view=true&view=net-android-34.0)
88

99

1010
# Project Docs
@@ -30,9 +30,9 @@
3030

3131
* [Build System Configuration](building/configuration.md)
3232
* [Build Dependencies for Linux and macOS](building/unix/dependencies.md)
33-
* [Building Xamarin.Android on Linux and macOS](building/unix/instructions.md)
33+
* [Building .NET for Android on Linux and macOS](building/unix/instructions.md)
3434
* [Build Dependencies for Windows](building/windows/dependencies.md)
35-
* [Building Xamarin.Android on Windows](building/windows/instructions.md)
35+
* [Building .NET for Android on Windows](building/windows/instructions.md)
3636

3737

3838
# Development Workflow
@@ -50,4 +50,4 @@
5050

5151
# Other Information
5252

53-
* [Wikipedia Entry for Xamarin.Android](https://en.wikipedia.org/wiki/Mono_(software)#Xamarin.Android)
53+
* [Wikipedia Entry for .NET for Android](https://en.wikipedia.org/w/index.php?title=.NET_for_Android&redirect=yes)

Documentation/binfmt_misc-warning-Linux.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Your Linux appears to have support for binfmt_misc kernel module enabled.
44
The module makes it possible to execute non-Linux binaries if the appropriate
55
interpreter for the given format is available.
66
Your machine is configured to handle Windows PE executables either via Mono or
7-
Wine. It will make the Xamarin.Android build fail IF you choose to build the
7+
Wine. It will make the .NET for Android build fail IF you choose to build the
88
Windows cross-compilers by enabling the 'mxe-Win32' or 'mxe-Win64' host targets.
99

1010
You can disable the binfmt_misc module by issuing the following command as root
11-
before building Xamarin.Android:
11+
before building .NET for Android:
1212

1313
echo 0 > /proc/sys/fs/binfmt_misc/status
1414

Documentation/building/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# Build Configuration
1111

12-
The Xamarin.Android build is heavily dependent on MSBuild, with the *intention*
12+
The .NET for Android build is heavily dependent on MSBuild, with the *intention*
1313
that it should (eventually?) be possible to build the project simply by
1414
checking out the repo, loading `Xamarin.Android.sln` into an IDE, and Building
1515
the solution. (This isn't currently possible, and may never be, but it's

Documentation/building/unix/dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Build Dependencies for Linux and macOS
22

3-
Building Xamarin.Android requires:
3+
Building .NET for Android requires:
44

55
* [Homebrew](#homebrew)
66
* [Latest Mono](#mono-sdk)

Documentation/building/unix/instructions.md

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Building Xamarin.Android on Linux and macOS
1+
# Building .NET for Android on Linux and macOS
22

3-
Building Xamarin.Android on Linux and macOS relies on GNU make and
3+
Building .NET for Android on Linux and macOS relies on GNU make and
44
MSBuild via the `msbuild` command (within Mono). MSBuild via `xbuild`
55
can also be used by setting the `$(MSBUILD)` make variable to `xbuild`.
66

7-
# Building Xamarin.Android
7+
# Building .NET for Android
88

99
1. Install the [build dependencies](dependencies.md).
1010

@@ -58,11 +58,11 @@ can also be used by setting the `$(MSBUILD)` make variable to `xbuild`.
5858
2019][xamdevsummit] with a full walkthrough. Even though the demo was
5959
on Windows, many of the concepts should still apply:
6060

61-
[![Build Xamarin.Android](https://img.youtube.com/vi/8qaQleb6Tbk/maxresdefault.jpg)][xamdevsummit]
61+
[![Build .NET for Android](https://img.youtube.com/vi/8qaQleb6Tbk/maxresdefault.jpg)][xamdevsummit]
6262

6363
[xamdevsummit]: https://youtu.be/8qaQleb6Tbk
6464

65-
# Creating a local .NET android Workload
65+
# Creating a local .NET for Android Workload
6666

6767
`make prepare` provisions a specific build of .NET to
6868
`bin/$(Configuration)/dotnet`.
@@ -95,12 +95,12 @@ See the [One .NET Documentation](../../guides/OneDotNet.md) for further details.
9595
# Creating installers
9696

9797
Once `make all` or `make jenkins` have completed, macOS (.pkg),
98-
Windows (.vsix), and .NET android workload .nupkg files
98+
Windows (.vsix), and .NET for Android workload .nupkg files
9999
can be built with:
100100

101101
make create-installers
102102

103-
Alternatively, .NET android workload packs can be built with:
103+
Alternatively, .NET for Android workload packs can be built with:
104104

105105
make create-nupkgs
106106
# -or-
@@ -351,23 +351,3 @@ For example, to rebuild Mono for armeabi-v7a:
351351
$ msbuild /t:_InstallRuntimes src/mono-runtimes/mono-runtimes.csproj
352352

353353

354-
# How do I rebuild BCL assemblies?
355-
356-
The Xamarin.Android Base Class Library assemblies, such as `mscorlib.dll`,
357-
are built within `external/mono`, using Mono's normal build system:
358-
359-
# This updates external/mono/mcs/class/lib/monodroid/ASSEMBLY.dll
360-
$ make -C external/mono/mcs/class/ASSEMBLY PROFILE=monodroid
361-
362-
Alternatively, if you want to rebuild *all* the assemblies, the "host"
363-
Mono needs to be rebuilt. Note that the name of the "host" directory
364-
varies based on the operating system you're building from:
365-
366-
$ make -C src/mono-runtimes/obj/Debug/host-Darwin
367-
368-
Once the assemblies have been rebuilt, they can be copied into the appropriate
369-
Xamarin.Android SDK directory by using the `_InstallBcl` target:
370-
371-
# This updates bin/$(Configuration)/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ASSEMBLY.dll
372-
$ msbuild src/mono-runtimes/mono-runtimes.csproj /t:_InstallBcl
373-

Documentation/building/windows/dependencies.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Build Dependencies for Windows
22

3-
Building Xamarin.Android requires:
3+
Building .NET for Android requires:
44

5-
* An existing installation of the Xamarin.Android SDK and the Android SDK
5+
* An existing installation of the .NET for Android SDK and the Android SDK
66
* The .NET Framework 3.5 – 4.7 development tools
77
* Git for Windows
88
* The Java Development Kit (JDK)

Documentation/building/windows/instructions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Building Xamarin.Android on Windows
1+
# Building .NET for Android on Windows
22

3-
Building Xamarin.Android on Windows requires .NET and the `msbuild` command
3+
Building .NET for Android on Windows requires .NET and the `msbuild` command
44
be available within the Command-Line environment.
55
(The **Developer Command Prompt** that Visual Studio installs is sufficient.)
66

77
MSBuild version 15 or later is required.
88

9-
# Building Xamarin.Android
9+
# Building .NET for Android
1010

1111
1. Install the [build dependencies](dependencies.md).
1212

@@ -80,13 +80,13 @@ So for example:
8080
[windows_path]: https://www.java.com/en/download/help/path.xml
8181
[set_alias]: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/set-alias?view=powershell-6
8282

83-
# Creating a local .NET android Workload
83+
# Creating a local .NET for Android Workload
8484

8585
`dotnet msbuild Xamarin.Android.sln -t:Prepare` provisions a
8686
specific build of .NET to `bin\$(Configuration)\dotnet`.
8787

8888
Once the prepare target is complete, you can set up a local
89-
.NET android workload install with:
89+
.NET for Android workload install with:
9090

9191
dotnet-local.cmd build Xamarin.Android.sln -t:BuildDotNet -m:1
9292

@@ -121,7 +121,7 @@ See the [One .NET Documentation](../../guides/OneDotNet.md) for further details.
121121
# Creating installers
122122

123123
Once `dotnet msbuild Xamarin.Android.sln -t:Prepare` is complete,
124-
.NET android workload packs can be built with:
124+
.NET for Android workload packs can be built with:
125125

126126
dotnet-local.cmd build Xamarin.Android.sln -t:BuildDotNet,PackDotNet -m:1
127127

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.

0 commit comments

Comments
 (0)