fix: build Android against the devbox-managed JDK and NDK
This commit is contained in:
parent
8426818712
commit
ac998b394d
5 changed files with 35 additions and 2 deletions
1
app/android/.gitignore
vendored
1
app/android/.gitignore
vendored
|
|
@ -1,5 +1,6 @@
|
||||||
gradle-wrapper.jar
|
gradle-wrapper.jar
|
||||||
/.gradle
|
/.gradle
|
||||||
|
/build
|
||||||
/captures/
|
/captures/
|
||||||
/gradlew
|
/gradlew
|
||||||
/gradlew.bat
|
/gradlew.bat
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,10 @@ plugins {
|
||||||
android {
|
android {
|
||||||
namespace = "page.mews.mews"
|
namespace = "page.mews.mews"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion = flutter.ndkVersion
|
// The devbox-managed SDK ships this NDK and is read-only, so Gradle
|
||||||
|
// cannot install the Flutter default beside it; the version is pinned to
|
||||||
|
// what nix-android-sdk provides.
|
||||||
|
ndkVersion = "27.0.12077973"
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,25 @@ subprojects {
|
||||||
project.evaluationDependsOn(":app")
|
project.evaluationDependsOn(":app")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The devbox-managed SDK ships one NDK and is read-only, so Gradle can never
|
||||||
|
// install another beside it. Plugin build scripts ask for Flutter's default
|
||||||
|
// NDK, which the SDK does not carry; every project is therefore pinned to
|
||||||
|
// the one it does. Matches the app's own pin in app/build.gradle.kts.
|
||||||
|
gradle.afterProject {
|
||||||
|
// The devbox-managed SDK ships one NDK and is read-only, so Gradle can
|
||||||
|
// never install another beside it. Plugin build scripts ask for
|
||||||
|
// Flutter's default NDK, which the SDK does not carry; every project
|
||||||
|
// is therefore pinned to the one it does, as the app itself is.
|
||||||
|
val android = extensions.findByName("android") ?: return@afterProject
|
||||||
|
try {
|
||||||
|
android::class.java
|
||||||
|
.getMethod("setNdkVersion", String::class.java)
|
||||||
|
.invoke(android, "27.0.12077973")
|
||||||
|
} catch (_: NoSuchMethodException) {
|
||||||
|
// Nothing to pin.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tasks.register<Delete>("clean") {
|
tasks.register<Delete>("clean") {
|
||||||
delete(rootProject.layout.buildDirectory)
|
delete(rootProject.layout.buildDirectory)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/main/schema/schemas/devbox.schema.json",
|
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/main/schema/schemas/devbox.schema.json",
|
||||||
"packages": {
|
"packages": {
|
||||||
"flutter@3.41.9-sdk-links": {},
|
"flutter@3.41.9-sdk-links": {},
|
||||||
|
"nixpkgs#openjdk17": {},
|
||||||
"path:./nix-android-sdk#android-sdk": {},
|
"path:./nix-android-sdk#android-sdk": {},
|
||||||
"gtk3": {},
|
"gtk3": {},
|
||||||
"clang": {},
|
"clang": {},
|
||||||
|
|
@ -10,10 +11,15 @@
|
||||||
"pkg-config": {},
|
"pkg-config": {},
|
||||||
"patchelf": {}
|
"patchelf": {}
|
||||||
},
|
},
|
||||||
|
"env": {
|
||||||
|
"ANDROID_HOME": "$DEVBOX_PACKAGES_DIR/share/android-sdk",
|
||||||
|
"ANDROID_SDK_ROOT": "$DEVBOX_PACKAGES_DIR/share/android-sdk"
|
||||||
|
},
|
||||||
"shell": {
|
"shell": {
|
||||||
"init_hook": [
|
"init_hook": [
|
||||||
"export PKG_CONFIG_PATH=\"$PWD/.devbox/nix/profile/default/lib/pkgconfig:$PKG_CONFIG_PATH\"",
|
"export PKG_CONFIG_PATH=\"$PWD/.devbox/nix/profile/default/lib/pkgconfig:$PKG_CONFIG_PATH\"",
|
||||||
"export LD_LIBRARY_PATH=\"$PWD/.devbox/nix/profile/default/lib:$LD_LIBRARY_PATH\""
|
"export LD_LIBRARY_PATH=\"$PWD/.devbox/nix/profile/default/lib:$LD_LIBRARY_PATH\"",
|
||||||
|
"flutter config --jdk-dir \"$(dirname \"$(dirname \"$(command -v java)\")\")\" > /dev/null"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"analyze": "cd app && flutter analyze",
|
"analyze": "cd app && flutter analyze",
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,10 @@
|
||||||
"resolved": "github:NixOS/nixpkgs/b6c8664de9b6cc07fe5666a29f91884ba81197c4?narHash=sha256-641r7xrlSOHYoktL9%2FaArPIYNgZJ9eM5URzSEOtPJDY%3D#ninja",
|
"resolved": "github:NixOS/nixpkgs/b6c8664de9b6cc07fe5666a29f91884ba81197c4?narHash=sha256-641r7xrlSOHYoktL9%2FaArPIYNgZJ9eM5URzSEOtPJDY%3D#ninja",
|
||||||
"source": "nixpkg"
|
"source": "nixpkg"
|
||||||
},
|
},
|
||||||
|
"nixpkgs#openjdk17": {
|
||||||
|
"last_modified": "1970-01-01T00:00:00Z",
|
||||||
|
"resolved": "path:/nix/store/v8ynlbrldn7k8byb1kx0j0wka8dsbrw9-source?narHash=sha256-BZWCi9ZRJiARTuKTbbtvFTj7t1TK4G3UEckT3HyNfRg%3D#openjdk17"
|
||||||
|
},
|
||||||
"patchelf": {
|
"patchelf": {
|
||||||
"resolved": "github:NixOS/nixpkgs/b6c8664de9b6cc07fe5666a29f91884ba81197c4?narHash=sha256-641r7xrlSOHYoktL9%2FaArPIYNgZJ9eM5URzSEOtPJDY%3D#patchelf",
|
"resolved": "github:NixOS/nixpkgs/b6c8664de9b6cc07fe5666a29f91884ba81197c4?narHash=sha256-641r7xrlSOHYoktL9%2FaArPIYNgZJ9eM5URzSEOtPJDY%3D#patchelf",
|
||||||
"source": "nixpkg"
|
"source": "nixpkg"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue