-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xamarin.Android project not building when using NDK r-22 #5526
Labels
Area: App+Library Build
Issues when building Library projects or Application projects.
Comments
lwschan
added
the
Area: App+Library Build
Issues when building Library projects or Application projects.
label
Jan 20, 2021
Hi @LewisGauss! Please use the workaround described here #5499 (comment). We are aware of the issue and we are working to implement a workaround (until NDK r22 is fixed) for this issue. Thanks! |
Merged
4 tasks
grendello
added a commit
to grendello/xamarin-android-tools
that referenced
this issue
Jan 20, 2021
Context: dotnet/android#5499 Context: dotnet/android#5526 Context: android/ndk#1427 Context: https://developer.android.com/studio/command-line/variables#envar Xamarin.Android is not (yet) compatible with the recently released Android NDK r22 version. Azure build images have recently rolled out an update which includes NDK r22 and, thus, it breaks builds for customers using any form of Xamarin.Android AOT build. In attempt to detect broken/incompatible NDK versions as well as select the "best one", this commit adds code to scan the known NDK locations in search of the preferred version. The search is conducted as follows: 1. If the user selected a preferred NDK location, it is always used. 2. Locations specified in the `ANDROID_{HOME,SDK_ROOT}` environment variables are returned next. 3. Directories in the `PATH` environment variable are examined to find a valid NDK location. 4. OS-specific known NDK locations are considered. For each of the returned locations, we now look for the Android SDK packages containing the NDK. There are two kinds of such packages: * `ndk-bundle` is the older package which allows for installation of only one NDK inside the SDK directory * `ndk/*` is a newer package which allows for installation of several NDK versions in parallel. Each subdirectory of `ndk` is an `X.Y.Z` version number of the NDK. In each of these directories we look for the `source.properties` file from which we then extract the NDK version and then we sort thus discovered NDK instances using their version as the key, in the descending order. The latest compatible (currently: less than 22 and more than 15) version is selected and its path returned to the caller.
This was referenced Jan 20, 2021
Merged
grendello
added a commit
to grendello/xamarin-android-tools
that referenced
this issue
Jan 20, 2021
Context: dotnet/android#5499 Context: dotnet/android#5526 Context: android/ndk#1427 Context: https://developer.android.com/studio/command-line/variables#envar Xamarin.Android is not (yet) compatible with the recently released Android NDK r22 version. Azure build images have recently rolled out an update which includes NDK r22 and, thus, it breaks builds for customers using any form of Xamarin.Android AOT build. In attempt to detect broken/incompatible NDK versions as well as select the "best one", this commit adds code to scan the known NDK locations in search of the preferred version. The search is conducted as follows: 1. If the user selected a preferred NDK location, it is always used. 2. Locations specified in the `ANDROID_{HOME,SDK_ROOT}` environment variables are returned next. 3. Directories in the `PATH` environment variable are examined to find a valid NDK location. 4. OS-specific known NDK locations are considered. For each of the returned locations, we now look for the Android SDK packages containing the NDK. There are two kinds of such packages: * `ndk-bundle` is the older package which allows for installation of only one NDK inside the SDK directory * `ndk/*` is a newer package which allows for installation of several NDK versions in parallel. Each subdirectory of `ndk` is an `X.Y.Z` version number of the NDK. In each of these directories we look for the `source.properties` file from which we then extract the NDK version and then we sort thus discovered NDK instances using their version as the key, in the descending order. The latest compatible (currently: less than 22 and more than 15) version is selected and its path returned to the caller.
grendello
added a commit
to grendello/xamarin-android-tools
that referenced
this issue
Jan 20, 2021
Context: dotnet/android#5499 Context: dotnet/android#5526 Context: android/ndk#1427 Context: https://developer.android.com/studio/command-line/variables#envar Xamarin.Android is not (yet) compatible with the recently released Android NDK r22 version. Azure build images have recently rolled out an update which includes NDK r22 and, thus, it breaks builds for customers using any form of Xamarin.Android AOT build. In attempt to detect broken/incompatible NDK versions as well as select the "best one", this commit adds code to scan the known NDK locations in search of the preferred version. The search is conducted as follows: 1. If the user selected a preferred NDK location, it is always used. 2. Locations specified in the `ANDROID_{HOME,SDK_ROOT}` environment variables are returned next. 3. Directories in the `PATH` environment variable are examined to find a valid NDK location. 4. OS-specific known NDK locations are considered. For each of the returned locations, we now look for the Android SDK packages containing the NDK. There are two kinds of such packages: * `ndk-bundle` is the older package which allows for installation of only one NDK inside the SDK directory * `ndk/*` is a newer package which allows for installation of several NDK versions in parallel. Each subdirectory of `ndk` is an `X.Y.Z` version number of the NDK. In each of these directories we look for the `source.properties` file from which we then extract the NDK version and then we sort thus discovered NDK instances using their version as the key, in the descending order. The latest compatible (currently: less than 22 and more than 15) version is selected and its path returned to the caller.
grendello
added a commit
to grendello/xamarin-android-tools
that referenced
this issue
Jan 20, 2021
Context: dotnet/android#5499 Context: dotnet/android#5526 Context: android/ndk#1427 Context: https://developer.android.com/studio/command-line/variables#envar Xamarin.Android is not (yet) compatible with the recently released Android NDK r22 version. Azure build images have recently rolled out an update which includes NDK r22 and, thus, it breaks builds for customers using any form of Xamarin.Android AOT build. In attempt to detect broken/incompatible NDK versions as well as select the "best one", this commit adds code to scan the known NDK locations in search of the preferred version. The search is conducted as follows: 1. If the user selected a preferred NDK location, it is always used. 2. Locations specified in the `ANDROID_{HOME,SDK_ROOT}` environment variables are returned next. 3. Directories in the `PATH` environment variable are examined to find a valid NDK location. 4. OS-specific known NDK locations are considered. For each of the returned locations, we now look for the Android SDK packages containing the NDK. There are two kinds of such packages: * `ndk-bundle` is the older package which allows for installation of only one NDK inside the SDK directory * `ndk/*` is a newer package which allows for installation of several NDK versions in parallel. Each subdirectory of `ndk` is an `X.Y.Z` version number of the NDK. In each of these directories we look for the `source.properties` file from which we then extract the NDK version and then we sort thus discovered NDK instances using their version as the key, in the descending order. The latest compatible (currently: less than 22 and more than 15) version is selected and its path returned to the caller.
jonpryor
pushed a commit
to dotnet/android-tools
that referenced
this issue
Jan 20, 2021
Context: actions/runner-images#2420 Context: dotnet/android#5499 Context: dotnet/android#5526 Context: android/ndk#1427 Context: https://developer.android.com/studio/command-line/variables#envar Xamarin.Android is not (yet) compatible with the recently released Android NDK r22 version. Azure build images have recently rolled out an update which includes NDK r22 and, thus, it breaks builds for customers using any form of Xamarin.Android AOT build. In an attempt to detect broken/incompatible NDK versions as well as to select the "best one", this commit adds code to scan the known NDK locations in search of the preferred version. Given an `AndroidSdkInfo` creation of: var info = new AndroidSdkInfo (logger:logger, androidSdkPath: sdkPath, androidNdkPath: ndkPath, javaSdkPath: javaPath); var usedNdkPath = info.AndroidNdkPath; If `ndkPath` is not `null` and otherwise valid, then `usedNdkPath` is `ndkPath`. If `ndkPath` is `null` or is otherwise invalid (missing `ndk-stack`, etc.), then we search for an `info.AndroidNdkPath` value as follows: 1. If `androidSdkPath` is not `null` and valid, then we check for Android SDK-relative NDK locations, in: * `{androidSdkPath}/ndk/*` * `{androidSdkPath}/ndk-bundle` For each found SDK-relative NDK directory, we filter out NDKs for which we cannot determine the package version, as well as those which are "too old" (< `MinimumCompatibleNDKMajorVersion`) or "too new" (> `MaximumCompatibleNDKMajorVersion`), currently r22. We prefer the NDK location with the highest version number. 2. If `androidSdkPath` is not `null` and valid and if there are no Android SDK-relative NDK locations, then we use the user-selected "preferred NDK location". See also `AndroidSdkInfo.SetPreferredAndroidNdkPath()`. 3. If `androidSdkPath` is not `null` and valid and if the preferred NDK location isn't set or is invalid, then we check directories specified in `$PATH`, and use the directory which contains `ndk-stack`. 4. If `androidSdkPath` is not `null` and valid and `$PATH` didn't contain `ndk-stack`, then we continue looking for NDK locations within the Android SDK locations specified by the `$ANDROID_HOME` and `$ANDROID_SDK_ROOT` environment variables. As with (1), these likewise look for e.g. `${ANDROID_HOME}/ndk/*` or `${ANDROID_SDK_ROOT}/ndk-bundle` directories and select the NDK with the highest supported version. 5. If `androidSdkPath` is `null`, then *first* we try to find a valid Android SDK directory, using on Unix: a. The preferred Android SDK directory; see also `AndroidSdkInfo.SetPreferredAndroidSdkPath(). b. The `$ANDROID_HOME` and `ANDROID_SDK_ROOT` environment variables. c. Directories within `$PATH` that contain `adb`. Once an Android SDK is found, steps (1)…(4) are performed. In (1) and (4), we now look for the Android SDK packages containing the NDK. There are two kinds of such packages: * `ndk-bundle` is the older package which allows for installation of only one NDK inside the SDK directory * `ndk/*` is a newer package which allows for installation of several NDK versions in parallel. Each subdirectory of `ndk` is an `X.Y.Z` version number of the NDK. In each of these directories we look for the `source.properties` file from which we then extract the NDK version and then we sort thus discovered NDK instances using their version as the key, in the descending order. The latest compatible (currently: less than 22 and more than 15) version is selected and its path returned to the caller.
jonpryor
pushed a commit
to dotnet/android-tools
that referenced
this issue
Jan 20, 2021
Context: actions/runner-images#2420 Context: dotnet/android#5499 Context: dotnet/android#5526 Context: android/ndk#1427 Context: https://developer.android.com/studio/command-line/variables#envar Xamarin.Android is not (yet) compatible with the recently released Android NDK r22 version. Azure build images have recently rolled out an update which includes NDK r22 and, thus, it breaks builds for customers using any form of Xamarin.Android AOT build. In an attempt to detect broken/incompatible NDK versions as well as to select the "best one", this commit adds code to scan the known NDK locations in search of the preferred version. Given an `AndroidSdkInfo` creation of: var info = new AndroidSdkInfo (logger:logger, androidSdkPath: sdkPath, androidNdkPath: ndkPath, javaSdkPath: javaPath); var usedNdkPath = info.AndroidNdkPath; If `ndkPath` is not `null` and otherwise valid, then `usedNdkPath` is `ndkPath`. If `ndkPath` is `null` or is otherwise invalid (missing `ndk-stack`, etc.), then we search for an `info.AndroidNdkPath` value as follows: 1. If `androidSdkPath` is not `null` and valid, then we check for Android SDK-relative NDK locations, in: * `{androidSdkPath}/ndk/*` * `{androidSdkPath}/ndk-bundle` For each found SDK-relative NDK directory, we filter out NDKs for which we cannot determine the package version, as well as those which are "too old" (< `MinimumCompatibleNDKMajorVersion`) or "too new" (> `MaximumCompatibleNDKMajorVersion`), currently r22. We prefer the NDK location with the highest version number. 2. If `androidSdkPath` is not `null` and valid and if there are no Android SDK-relative NDK locations, then we use the user-selected "preferred NDK location". See also `AndroidSdkInfo.SetPreferredAndroidNdkPath()`. 3. If `androidSdkPath` is not `null` and valid and if the preferred NDK location isn't set or is invalid, then we check directories specified in `$PATH`, and use the directory which contains `ndk-stack`. 4. If `androidSdkPath` is not `null` and valid and `$PATH` didn't contain `ndk-stack`, then we continue looking for NDK locations within the Android SDK locations specified by the `$ANDROID_HOME` and `$ANDROID_SDK_ROOT` environment variables. As with (1), these likewise look for e.g. `${ANDROID_HOME}/ndk/*` or `${ANDROID_SDK_ROOT}/ndk-bundle` directories and select the NDK with the highest supported version. 5. If `androidSdkPath` is `null`, then *first* we try to find a valid Android SDK directory, using on Unix: a. The preferred Android SDK directory; see also `AndroidSdkInfo.SetPreferredAndroidSdkPath(). b. The `$ANDROID_HOME` and `ANDROID_SDK_ROOT` environment variables. c. Directories within `$PATH` that contain `adb`. Once an Android SDK is found, steps (1)…(4) are performed. In (1) and (4), we now look for the Android SDK packages containing the NDK. There are two kinds of such packages: * `ndk-bundle` is the older package which allows for installation of only one NDK inside the SDK directory * `ndk/*` is a newer package which allows for installation of several NDK versions in parallel. Each subdirectory of `ndk` is an `X.Y.Z` version number of the NDK. In each of these directories we look for the `source.properties` file from which we then extract the NDK version and then we sort thus discovered NDK instances using their version as the key, in the descending order. The latest compatible (currently: less than 22 and more than 15) version is selected and its path returned to the caller.
ghost
locked as resolved and limited conversation to collaborators
Jun 3, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Recently, some changes were made to the macOS image, updating the Android NDK bundle from r-21 to r-22. Ever since the update, many Xamarin.Android projects have had problems building.
Refer to https://developercommunity2.visualstudio.com/t/error-xa5101-platform-library-directory-for-target/1313156?from=email and actions/runner-images#2481 and actions/runner-images#2481
In the Microsoft Developer Community thread, a solution provided by one of the commetors is to install NDK r-21 manually, and use msbuildArguments in the Xamarin.Android build task to force it to choose the NDK installed. This step cannot work for App Center, because App Center does not allow us to pass in any argument for the build task.
Is there a way to force Xamarin.Android project to use the newest NDK version installed? Instead of trying to use an old one. We are not targetting any specific NDK version in our app, I also couldn't find a config to change it. So I am not sure why the build task is trying to use such an old version.
Tested using Xamarin.Android 11.1 and 10.3, same result.
Steps to Reproduce
Expected Behavior
Build without error.
Actual Behavior
The text was updated successfully, but these errors were encountered: