Skip to content
main
Switch branches/tags
Code

Latest commit

Context: https://dl-ssl.google.com/android/repository/repository2-1.xml

We were seeing some lint-related MSBuild tests fail with:

	Lint
	    Parameters
	        ToolPath = /Users/runner/Library/Android/sdk/cmdline-tools/latest/bin
	    ...
	    LintVersion: 4.2.0
	    Environment Variables passed to tool:
	    JAVA_HOME=/Users/runner/Library/Android/jdk-11/
	    ...
	    Errors
	        obj/Debug/android/AndroidManifest.xml(12,89): error XA0103:  MainActivity must extend android.app.Activity [Instantiatable] [/Users/runner/work/1/s/bin/TestRelease/temp/CheckLintConfigMerging/UnnamedProject.csproj]
	        obj/Debug/android/AndroidManifest.xml(18,28): error XA0103:  MonoRuntimeProvider must extend android.content.ContentProvider [Instantiatable] [/Users/runner/work/1/s/bin/TestRelease/temp/CheckLintConfigMerging/UnnamedProject.csproj]
	    2 errors, 3 warnings
	    The command exited with code -1.

We suspect the Hosted Agent pool was updated to install
`cmdline-tools` 4.0 into `~/Library/Android/sdk/cmdline-tools/latest`,
which caused this problem:

  * https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#android

After updating locally to `cmdline-tools` 4.0 I can reproduce the issue.

I also updated the `<Lint/>` MSBuild task to ignore the
`Instantiatable` error for now.

After this change, emulators failed to start:

	Task CreateAndroidEmulator
	...
	build-tools/scripts/TestApks.targets(52,5): Config file for AVD 'XamarinAndroidTestRunner29-x86_64' not found at /Users/runner/.android/avd/XamarinAndroidTestRunner29-x86_64.avd/config.ini [/Users/runner/work/1/s/tests/Mono.Android-Tests/Mono.Android-Tests.csproj]
	build-tools/scripts/TestApks.targets(52,5): AVD 'XamarinAndroidTestRunner29-x86_64' will use default emulator settings (memory and data partition size) [/Users/runner/work/1/s/tests/Mono.Android-Tests/Mono.Android-Tests.csproj]
	...
	Task StartAndroidEmulator
	...
	build-tools/scripts/TestApks.targets(65,5): Emulator failed to start: emulator: ERROR: Unknown AVD name [XamarinAndroidTestRunner29-x86_64], use -list-avds to see valid list. [/Users/runner/work/1/s/tests/Mono.Android-Tests/Mono.Android-Tests.csproj]

It appears the code in the `<CreateAndroidEmulator/>` MSBuild task
that attempts to pass `\n` to stdin is no longer working?

`avdmanager` now prompts with:

	Do you wish to create a custom hardware profile? [no]

I found that if you pass `--device pixel_4`, for example, then
`avdmanager` does not prompt at all.  I think we should select a
default device, so we don't have to work with stdin at all.

I converted `<CreateAndroidEmulator/>` to a regular `ToolTask` and
passed `--device`. The command appears to work properly now.

Additionally, we were previously setting `$ANDROID_SDK_HOME` to the
actual path of our Android SDK, which causes `avdmanager` to print
warnings such as:

	Warning: ANDROID_SDK_HOME is set to the root of your SDK: /Users/runner/Library/Android/sdk
	ANDROID_SDK_HOME is meant to be the path of the preference folder expected by the Android tools.

It appears that `avdmanager` expects `$ANDROID_SDK_HOME` to point to
a location where it will create a new `.android` folder with AVDs.

I created a new `$(AvdManagerHome)` property to be used by the
`<StartAndroidEmulator/>` and `<CreateAndroidEmulator/>` MSBuild
tasks.  We now have full control of where the `.android` folder is
located, which will be `~/android-toolchain/.android` by default.
92efdcc

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time

Xamarin.Android banner

Xamarin.Android

Xamarin.Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#.

Build Status

Platform Status
OSS macOS OSS macOS x86_64
OSS Ubuntu OSS Linux/Ubuntu x86_64

Downloads

Current

Platform Link
Commercial Xamarin.Android 11.2 (d16-9) Preview for Windows+Visual Studio 2019 Preview Download
Commercial Xamarin.Android 11.2 (d16-9) Preview for macOS Download
Commercial Xamarin.Android 11.1 (d16-8) for Windows+Visual Studio 2019 Download
Commercial Xamarin.Android 11.1 (d16-8) for macOS Download
OSS Xamarin.Android 11.1.99 (master) for Ubuntu* OSS Linux/Ubuntu x86_64

* Please note that the OSS installer packages are not digitally signed.

Previous

Platform Link
Commercial Xamarin.Android 11.0 (d16-7) for Windows+Visual Studio 2019 Download
Commercial Xamarin.Android 11.0 (d16-7) for macOS Download
Commercial Xamarin.Android 10.3 (d16-6) for Windows+Visual Studio 2019 Download
Commercial Xamarin.Android 10.3 (d16-6) for macOS Download
Commercial Xamarin.Android 10.2 (d16-5) for Windows+Visual Studio 2019 Download
Commercial Xamarin.Android 10.2 (d16-5) for macOS Download
Commercial Xamarin.Android 10.1 (d16-4) for Windows+Visual Studio 2019 Download
Commercial Xamarin.Android 10.1 (d16-4) for macOS Download
Commercial Xamarin.Android 10.0 (d16-3) for Windows+Visual Studio 2019 Download
Commercial Xamarin.Android 10.0 (d16-3) for macOS Download
Commercial Xamarin.Android 9.4 (d16-2) for Windows+Visual Studio 2019 Download
Commercial Xamarin.Android 9.4 (d16-2) for macOS Download
Commercial Xamarin.Android 9.3 (d16-1) for Windows+Visual Studio 2019 Download
Commercial Xamarin.Android 9.3 (d16-1) for macOS Download
Commercial Xamarin.Android 9.2 (d16-0) for Windows+Visual Studio 2019 Download
Commercial Xamarin.Android 9.2 (d16-0) for macOS Download
Commercial Xamarin.Android 9.1 (d15-9) for macOS & Windows+Visual Studio 2017 Commercial Xamarin.Android 9.1, macOS+VS2017
Commercial Xamarin.Android 9.0 (d15-8) for macOS & Windows+Visual Studio 2017 Commercial Xamarin.Android 9.0, macOS+VS2017

Contributing

If you are interested in fixing issues and contributing directly to the code base, please see the following:

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the .NET Foundation Code of Conduct.

Feedback

Discord

License

Copyright (c) .NET Foundation Contributors. All rights reserved. Licensed under the MIT License.

About

Xamarin.Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#

Resources

License

Packages

No packages published