Skip to content

InstallAndroidDependencies target doesn't install platform-tools and other necessary parts of the SDK. #7284

Closed
@Lauriethefish

Description

@Lauriethefish

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

.NET 6.0.400

Description

When installing the android SDK using the InstallAndroidDependencies target, the downloaded SDK is missing key tools, such as aapt and platform-tools:

laurie@d95389ff63a7:/opt/android-sdk$ ls
platforms

This causes a build with the installed SDK to fail with error XA5300, since Xamarin discards your selected SDK directory when it thinks it's invalid. (perhaps a better error message would be great here, but not super important for this issue).

It would be great if this could be fixed since this target is very, very helpful for CI.

Steps to Reproduce

  1. Start a docker container with the mcr.microsoft.com/dotnet/sdk:6.0 image.
  2. Create a new user, make them a sudoer, and log into the user with su.
  3. Install the android workload sudo dotnet workload install android.
  4. Create a new net6.0-android project: sudo dotnet new android -o example && cd example.
  5. Restore the project: sudo dotnet restore ./example.csproj
  6. Invoke InstallAndroidDependencies to download the SDK: sudo dotnet msbuild ./example.csproj -t:InstallAndroidDependencies -p:AndroidSdkDirectory=/opt/android-sdk -p:AcceptAndroidSDKLicenses=true
  7. Attempt to use the new android SDK directory to build the project: sudo dotnet publish -c Release -p:AndroidSdkDirectory=/opt/android-sdk.
    You will then receive the error: /usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/32.0.448/tools/Xamarin.Android.Tooling.targets(69,5): error XA5300: The Android SDK directory could not be found. Check that the Android SDK Manager in Visual Studio shows a valid installation. To use a custom SDK path for a command line build, set the 'AndroidSdkDirectory' MSBuild property to the custom path. [/home/laurie/example/example.csproj]

Did you find any workaround?

No workaround currently, I tried installing the SDK with sudo apt-get install -y android-sdk, but unfortunately that SDK only targets API level 29, and we need API level 31 for net6.0-android.

Relevant log output

See comment for diagnostic logs of both InstallAndroidDepencies and publish.

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.bugComponent does not function as intended.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions