androidenv: fix new "37.0" packages with API version ranges (#507124)

This commit is contained in:
Alexandre Esteves
2026-04-07 22:44:35 +00:00
committed by GitHub
5 changed files with 1863 additions and 688 deletions
@@ -298,7 +298,8 @@ let
# Returns true if the given version exists.
hasVersion =
packages: package: version:
lib.hasAttrByPath [ package (toString version) ] packages;
lib.hasAttrByPath [ package (toString version) ] packages
|| lib.hasAttrByPath [ package "${(toString version)}.0" ] packages;
# Displays a nice error message that includes the available options if a version doesn't exist.
# Note that allPackages can be a list of package sets, or a single package set. Pass a list if
@@ -322,7 +323,7 @@ let
}.
''
else
packageSet.${package}.${toString version};
packageSet.${package}.${toString version} or packageSet.${package}."${toString version}.0";
# Returns true if we should link the specified plugins.
shouldLink =
@@ -546,12 +547,25 @@ lib.recurseIntoAttrs rec {
}
) platformVersions';
sources = map (
version:
deployAndroidPackage {
package = checkVersion allArchives.packages "sources" version;
}
) platformVersions';
# Google is not including sources for API 37+. If the user requests them, don't fail.
sources = lib.filter (source: source != null) (
map (
version:
let
package =
let
version' = builtins.tryEval (checkVersion allArchives.packages "sources" version);
in
if version'.success then version'.value else null;
in
if package == null then
null
else
deployAndroidPackage {
inherit package;
}
) platformVersions'
);
system-images = lib.flatten (
map (
@@ -37,6 +37,7 @@ deployAndroidPackage {
nspr
alsa-lib
waylandpp.lib
libgbm
]
)
++ (with pkgs; [
@@ -128,7 +128,7 @@ pkgs.mkShell rec {
packages=(
"build-tools" "cmdline-tools" \
"platform-tools" "platforms;android-${toString latestSdkVersion}" \
"system-images;android-${toString latestSdkVersion};google_apis;x86_64"
"system-images;android-${toString latestSdkVersion};google_apis_ps16k;x86_64"
)
${lib.optionalString emulatorSupported ''packages+=("emulator")''}
@@ -158,7 +158,6 @@ pkgs.mkShell rec {
for x in $(seq 1 ${lib.versions.major (toString latestSdkVersion)}); do
excluded_packages+=(
"platforms;android-$x"
"sources;android-$x"
"system-images;android-$x"
)
done
@@ -188,7 +187,7 @@ pkgs.mkShell rec {
mkdir -p $ANDROID_USER_HOME
avdmanager delete avd -n testAVD || true
echo "" | avdmanager create avd --force --name testAVD --package 'system-images;android-${toString latestSdkVersion};google_apis;x86_64'
{ echo "" | avdmanager create avd --force --name testAVD --package 'system-images;android-${toString latestSdkVersion};google_apis_ps16k;x86_64'; }
result=$(avdmanager list avd)
if [[ ! $result =~ "Name: testAVD" ]]; then
@@ -187,10 +187,6 @@ pkgs.mkShell rec {
"extras;google;gcm"
)
for x in $(seq ${toString firstSdkVersion} ${toString latestSdkVersion}); do
packages+=("sources;android-$x")
done
${lib.optionalString includeAuto ''packages+=("extras;google;auto")''}
for package in "''${packages[@]}"; do
File diff suppressed because it is too large Load Diff