From 358669a82fa960f123a7694b963c21ea27f8610e Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Fri, 11 Nov 2022 16:31:31 -0500 Subject: [PATCH] Somewhat less gross aapt2 management --- app/gradle.properties | 8 ------- flake.nix | 53 ++++++++++++++++--------------------------- 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/app/gradle.properties b/app/gradle.properties index 6743e4c..3c7a8bd 100644 --- a/app/gradle.properties +++ b/app/gradle.properties @@ -21,11 +21,3 @@ kotlin.code.style=official # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true - -# What an atrocious path, you say. Well, yes. It doesn't make a ton of sense -# to have this checked in. However, it seems like the other properties here -# should be checked in and also this setting seems to *have* to go in this -# file (instead of, say, local.properties). The devShell provided by the -# flake will rewrite this path at activation time if it needs to be different! -# So maybe focus on bigger problems for a while. -android.aapt2FromMavenOverride=/nix/store/n7mv52lj2alq2gkys0skwwgs6c7s1cyl-androidsdk/libexec/android-sdk/build-tools/31.0.0/aapt2 diff --git a/flake.nix b/flake.nix index a781c48..101a6ca 100644 --- a/flake.nix +++ b/flake.nix @@ -89,10 +89,24 @@ getBuildInputs = getInputs: xs: builtins.foldl' (accum: drv: (getInputs drv) ++ accum) [] xs; - chaquopy-env = mach-nix.mkPython { - python = "python39"; - requirements = '' - chaquopy + # Make sure gradle uses the aapt2 from our Android SDK. Otherwise it + # downloads one from the internet that doesn't work because it + # specifies an interpreter (ld.so) that nothing has ensured will + # exist. + # + # Without this you get a stack of build errors that look a bit like: + # + # Execution failed for task ':app:processDebugResources'. + # > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. + # > Failed to transform appcompat-1.3.0.aar (androidx.appcompat:appcompat:1.3.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. + # > Execution failed for AarResourcesCompilerTransform: /home/exarkun/.gradle/caches/transforms-3/f5908003b5fc10a9cf0fd543db10ae32/transformed/appcompat-1.3.0. + # > AAPT2 aapt2-7.2.1-7984345-linux Daemon #1: Daemon startup failed + # This should not happen under normal circumstances, please file an issue if it does. + ANDROIDSDK = "${androidComposition.androidsdk}/libexec/android-sdk"; + gradle-wrapper = pkgs.writeShellApplication { + name = "gradle"; + text = '' + ${pkgs.gradle}/bin/gradle -Pandroid.aapt2FromMavenOverride=${ANDROIDSDK}/build-tools/${buildToolsVersion}/aapt2 "$@" ''; }; in { @@ -125,7 +139,7 @@ name = "nix-native"; version = "2022.11.09"; - ANDROIDSDK = "${androidComposition.androidsdk}/libexec/android-sdk"; + inherit ANDROIDSDK; ANDROIDNDK = "${ANDROIDSDK}/ndk-bundle"; ANDROID_SDK_ROOT = ANDROIDSDK; @@ -134,23 +148,8 @@ # Deprecated but ... :shrug: ANDROID_HOME = ANDROIDSDK; - # Make sure gradle uses the aapt2 from our Android SDK. Otherwise it - # downloads one from the internet that doesn't work because it - # specifies an interpreter (ld.so) that nothing has ensures will - # exist. - # - # Without this you get a stack of build errors that look a bit like: - # - # Execution failed for task ':app:processDebugResources'. # - # > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. - # > Failed to transform appcompat-1.3.0.aar (androidx.appcompat:appcompat:1.3.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. - # > Execution failed for AarResourcesCompilerTransform: /home/exarkun/.gradle/caches/transforms-3/f5908003b5fc10a9cf0fd543db10ae32/transformed/appcompat-1.3.0. - # > AAPT2 aapt2-7.2.1-7984345-linux Daemon #1: Daemon startup failed - # This should not happen under normal circumstances, please file an issue if it does. - # GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROIDSDK}/build-tools/${buildToolsVersion}/aapt2"; - buildInputs = with pkgs; [ - gradle + gradle-wrapper ant android-studio android-tools @@ -166,18 +165,6 @@ sdk.dir=${ANDROIDSDK} EOF - - sed -i -e 's,aapt2FromMavenOverride=.*,aapt2FromMavenOverride=${ANDROIDSDK}/build-tools/${buildToolsVersion}/aapt2,' app/gradle.properties - - # This probably needs to be set somewhere, but perhaps not here? - # - # > [CXX5106] NDK was located by using ndk.dir property. This method - # > is deprecated and will be removed in a future release. Please delete - # > ndk.dir from local.properties and set android.ndkVersion to - # > [23.0.7123448] in all native modules in the project. - # > https://developer.android.com/r/studio-ui/ndk-dir - # android.ndkVersion=${ndkVersion} - ''; }; -- GitLab