Skip to content

AndroidSdkInfo.AndroidNdkPath & ndk-bundle #92

@jonpryor

Description

@jonpryor

Context: PR #90
Context: https://dev.azure.com/xamarin/public/_build/results?buildId=21603&view=logs&j=2d2b3007-3c5c-5840-9bb0-2b1ea49925f3

The "unrelated test failure" on Windows is because Windows is non-deterministic: the test asserts that given an Android SDK directory androidSdk which contains the file {androidSdk}\ndk-bundle\ndk-stack.cmd, then this:

var info = new AndroidSdkInfo (logger: null, androidSdkPath: androidSdk);

will return {androidSdk}\ndk-bundle as the info.AndroidNdkPath value.

The problem is that the info.AndroidNdkPath logic involves is doomed to fail. For starters, if the Registry has an NDK path configured, it is preferred:

https://github.com/xamarin/xamarin-android-tools/blob/3974fc38c0f25f943b5d3bf0a4e174532a2a60ee/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkBase.cs#L61

If the Registry doesn't have a preferred NDK value, then we hit AndroidSdkWindows.GetAllAvailableAndroidNdks(), which involves a .Distinct() call:

https://github.com/xamarin/xamarin-android-tools/blob/3974fc38c0f25f943b5d3bf0a4e174532a2a60ee/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkWindows.cs#L224-L268

which means that the order of returned directories is unknowable and may (will?) vary from test run to test run.

This is, in short, a highly "unstable" algorithm which won't be consistent from one run to the next. Which explains why it sometimes fails, and sometimes doesn't. :-(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions