diff --git a/.ci.yaml b/.ci.yaml index 57d08af984..a5eb7ddba6 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -5503,7 +5503,7 @@ targets: add_recipes_cq: "true" dependencies: >- [ - {"dependency": "android_sdk", "version": "version:33v6"}, + {"dependency": "android_sdk", "version": "version:35v1"}, {"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}, {"dependency": "open_jdk", "version": "version:17"}, {"dependency": "goldctl", "version": "git_revision:2387d6fff449587eecbb7e45b2692ca0710b63b9"}, @@ -5521,7 +5521,7 @@ targets: add_recipes_cq: "true" dependencies: >- [ - {"dependency": "android_sdk", "version": "version:33v6"}, + {"dependency": "android_sdk", "version": "version:35v1"}, {"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}, {"dependency": "open_jdk", "version": "version:17"}, {"dependency": "goldctl", "version": "git_revision:2387d6fff449587eecbb7e45b2692ca0710b63b9"}, @@ -5539,7 +5539,7 @@ targets: add_recipes_cq: "true" dependencies: >- [ - {"dependency": "android_sdk", "version": "version:33v6"}, + {"dependency": "android_sdk", "version": "version:35v1"}, {"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"}, {"dependency": "open_jdk", "version": "version:17"}, {"dependency": "goldctl", "version": "git_revision:2387d6fff449587eecbb7e45b2692ca0710b63b9"}, diff --git a/dev/a11y_assessments/android/app/build.gradle b/dev/a11y_assessments/android/app/build.gradle index c911663423..d040546cc3 100644 --- a/dev/a11y_assessments/android/app/build.gradle +++ b/dev/a11y_assessments/android/app/build.gradle @@ -35,7 +35,15 @@ if (keystorePropertiesFile.exists()) { android { namespace "com.example.a11y_assessments" compileSdk flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/benchmarks/complex_layout/android/app/build.gradle b/dev/benchmarks/complex_layout/android/app/build.gradle index f86cb35c1d..8b00ebb415 100644 --- a/dev/benchmarks/complex_layout/android/app/build.gradle +++ b/dev/benchmarks/complex_layout/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace "com.yourcompany.complexLayout" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 diff --git a/dev/benchmarks/macrobenchmarks/android/app/build.gradle b/dev/benchmarks/macrobenchmarks/android/app/build.gradle index 06acb88de4..f358286d00 100644 --- a/dev/benchmarks/macrobenchmarks/android/app/build.gradle +++ b/dev/benchmarks/macrobenchmarks/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace "com.example.macrobenchmarks" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/benchmarks/microbenchmarks/android/app/build.gradle b/dev/benchmarks/microbenchmarks/android/app/build.gradle index 141ac9622f..e3fc68e472 100644 --- a/dev/benchmarks/microbenchmarks/android/app/build.gradle +++ b/dev/benchmarks/microbenchmarks/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace "com.yourcompany.microbenchmarks" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/benchmarks/multiple_flutters/android/app/build.gradle b/dev/benchmarks/multiple_flutters/android/app/build.gradle index 6a671e475e..9cea465111 100644 --- a/dev/benchmarks/multiple_flutters/android/app/build.gradle +++ b/dev/benchmarks/multiple_flutters/android/app/build.gradle @@ -16,6 +16,15 @@ android { namespace "dev.flutter.multipleflutters" compileSdk 34 + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = "26.3.11579264" // This version must exactly match the version of the NDK that the recipe pulls from CIPD. + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/benchmarks/platform_views_layout/android/app/build.gradle b/dev/benchmarks/platform_views_layout/android/app/build.gradle index 63c7e0bee4..9504f0ae17 100644 --- a/dev/benchmarks/platform_views_layout/android/app/build.gradle +++ b/dev/benchmarks/platform_views_layout/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace "dev.benchmarks.platform_views_layout" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/benchmarks/platform_views_layout_hybrid_composition/android/app/build.gradle b/dev/benchmarks/platform_views_layout_hybrid_composition/android/app/build.gradle index 2beb7dc539..ee181f49dc 100644 --- a/dev/benchmarks/platform_views_layout_hybrid_composition/android/app/build.gradle +++ b/dev/benchmarks/platform_views_layout_hybrid_composition/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace "dev.benchmarks.platform_views_layout_hybrid_composition" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/benchmarks/test_apps/stocks/android/app/build.gradle b/dev/benchmarks/test_apps/stocks/android/app/build.gradle index 5e7907e25e..6dbd28b9da 100644 --- a/dev/benchmarks/test_apps/stocks/android/app/build.gradle +++ b/dev/benchmarks/test_apps/stocks/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace "io.flutter.examples.stocks" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/devicelab/bin/tasks/gradle_desugar_classes_test.dart b/dev/devicelab/bin/tasks/gradle_desugar_classes_test.dart index 2d6062ed35..5427ab8bd4 100644 --- a/dev/devicelab/bin/tasks/gradle_desugar_classes_test.dart +++ b/dev/devicelab/bin/tasks/gradle_desugar_classes_test.dart @@ -15,7 +15,7 @@ Future main() async { try { await runProjectTest((FlutterProject flutterProject) async { section('APK contains plugin classes'); - await flutterProject.setMinSdkVersion(20); + await flutterProject.setMinSdkVersion(21); await flutterProject.addPlugin('google_maps_flutter:^2.2.1'); await inDirectory(flutterProject.rootPath, () async { diff --git a/dev/integration_tests/android_semantics_testing/android/app/build.gradle b/dev/integration_tests/android_semantics_testing/android/app/build.gradle index 25afe619de..1bcd40e4a3 100644 --- a/dev/integration_tests/android_semantics_testing/android/app/build.gradle +++ b/dev/integration_tests/android_semantics_testing/android/app/build.gradle @@ -20,6 +20,15 @@ android { namespace = "com.yourcompany.platforminteraction" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/android_verified_input/android/app/build.gradle b/dev/integration_tests/android_verified_input/android/app/build.gradle index 995fb86b32..e6f0187e1e 100644 --- a/dev/integration_tests/android_verified_input/android/app/build.gradle +++ b/dev/integration_tests/android_verified_input/android/app/build.gradle @@ -29,7 +29,15 @@ if (flutterVersionName == null) { android { namespace "io.flutter.integration.android_verified_input" compileSdk flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/android_views/android/app/build.gradle b/dev/integration_tests/android_views/android/app/build.gradle index 8596326f55..a376d48367 100644 --- a/dev/integration_tests/android_views/android/app/build.gradle +++ b/dev/integration_tests/android_views/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace = 'io.flutter.integration.platformviews' compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/channels/android/app/build.gradle b/dev/integration_tests/channels/android/app/build.gradle index 17f8f1332c..29638d599d 100644 --- a/dev/integration_tests/channels/android/app/build.gradle +++ b/dev/integration_tests/channels/android/app/build.gradle @@ -29,7 +29,15 @@ if (flutterVersionName == null) { android { namespace "com.example.channels" compileSdk flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/deferred_components_test/android/app/build.gradle b/dev/integration_tests/deferred_components_test/android/app/build.gradle index 69750fb03d..f17f930b4b 100644 --- a/dev/integration_tests/deferred_components_test/android/app/build.gradle +++ b/dev/integration_tests/deferred_components_test/android/app/build.gradle @@ -36,6 +36,15 @@ android { namespace "io.flutter.integration.deferred_components_test" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + sourceSets { main.java.srcDirs += 'src/main/kotlin' } diff --git a/dev/integration_tests/deferred_components_test/android/component1/build.gradle b/dev/integration_tests/deferred_components_test/android/component1/build.gradle index 9daab6d9c9..5354de1031 100644 --- a/dev/integration_tests/deferred_components_test/android/component1/build.gradle +++ b/dev/integration_tests/deferred_components_test/android/component1/build.gradle @@ -26,6 +26,15 @@ android { namespace "io.flutter.integration.deferred_components_test.component1" compileSdk 35 + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = "26.3.11579264" // This version must exactly match the version of the NDK that the recipe pulls from CIPD. + ndkPath = systemNdkPath + } + sourceSets { applicationVariants.all { variant -> main.assets.srcDirs += "${project.layout.buildDirectory.get()}/intermediates/flutter/${variant.name}/deferred_assets" diff --git a/dev/integration_tests/external_textures/android/app/build.gradle b/dev/integration_tests/external_textures/android/app/build.gradle index 7e1c89b3a5..c6adeef108 100644 --- a/dev/integration_tests/external_textures/android/app/build.gradle +++ b/dev/integration_tests/external_textures/android/app/build.gradle @@ -19,6 +19,15 @@ android { namespace = "io.flutter.externalui" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/flavors/android/app/build.gradle b/dev/integration_tests/flavors/android/app/build.gradle index 5b091f702a..9044bc258a 100644 --- a/dev/integration_tests/flavors/android/app/build.gradle +++ b/dev/integration_tests/flavors/android/app/build.gradle @@ -19,6 +19,15 @@ android { namespace "com.yourcompany.flavors" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/flutter_gallery/android/app/build.gradle b/dev/integration_tests/flutter_gallery/android/app/build.gradle index 5c5fa7d61c..df976a59cd 100644 --- a/dev/integration_tests/flutter_gallery/android/app/build.gradle +++ b/dev/integration_tests/flutter_gallery/android/app/build.gradle @@ -45,6 +45,15 @@ android { namespace "io.flutter.demo.gallery" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/gradle_deprecated_settings/android/app/build.gradle b/dev/integration_tests/gradle_deprecated_settings/android/app/build.gradle index ecb2deeb6d..64c3432e3b 100644 --- a/dev/integration_tests/gradle_deprecated_settings/android/app/build.gradle +++ b/dev/integration_tests/gradle_deprecated_settings/android/app/build.gradle @@ -22,6 +22,15 @@ android { namespace = "com.yourcompany.flavors" compileSdk 34 + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/hybrid_android_views/android/app/build.gradle b/dev/integration_tests/hybrid_android_views/android/app/build.gradle index 5fb0d47446..b595440083 100644 --- a/dev/integration_tests/hybrid_android_views/android/app/build.gradle +++ b/dev/integration_tests/hybrid_android_views/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace = "io.flutter.integration.platformviews" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/module_host_with_custom_build_v2_embedding/app/build.gradle b/dev/integration_tests/module_host_with_custom_build_v2_embedding/app/build.gradle index 1e69c1f986..75f07cb601 100644 --- a/dev/integration_tests/module_host_with_custom_build_v2_embedding/app/build.gradle +++ b/dev/integration_tests/module_host_with_custom_build_v2_embedding/app/build.gradle @@ -8,6 +8,15 @@ android { namespace = "io.flutter.addtoapp" compileSdk 34 + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = "26.3.11579264" // This version must exactly match the version of the NDK that the recipe pulls from CIPD. + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/native_driver_test/android/app/build.gradle b/dev/integration_tests/native_driver_test/android/app/build.gradle index c5b106e0c9..4734c2bdd7 100644 --- a/dev/integration_tests/native_driver_test/android/app/build.gradle +++ b/dev/integration_tests/native_driver_test/android/app/build.gradle @@ -12,7 +12,15 @@ plugins { android { namespace = "com.example.native_driver_test" compileSdk = flutter.compileSdkVersion - ndkVersion = flutter.ndkVersion + + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/non_nullable/android/app/build.gradle b/dev/integration_tests/non_nullable/android/app/build.gradle index 9822c24687..3b305e5ad8 100644 --- a/dev/integration_tests/non_nullable/android/app/build.gradle +++ b/dev/integration_tests/non_nullable/android/app/build.gradle @@ -30,6 +30,15 @@ android { namespace = "com.example.non_nullable" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/platform_interaction/android/app/build.gradle b/dev/integration_tests/platform_interaction/android/app/build.gradle index 7f8fea246c..5dfccb53e2 100644 --- a/dev/integration_tests/platform_interaction/android/app/build.gradle +++ b/dev/integration_tests/platform_interaction/android/app/build.gradle @@ -19,6 +19,15 @@ android { namespace = "com.yourcompany.platforminteraction" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/pure_android_host_apps/android_custom_host_app/SampleApp/build.gradle b/dev/integration_tests/pure_android_host_apps/android_custom_host_app/SampleApp/build.gradle index 1ec1e7bc65..0227cf37b2 100644 --- a/dev/integration_tests/pure_android_host_apps/android_custom_host_app/SampleApp/build.gradle +++ b/dev/integration_tests/pure_android_host_apps/android_custom_host_app/SampleApp/build.gradle @@ -8,6 +8,15 @@ android { namespace = "io.flutter.add2app" compileSdk 34 + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = "26.3.11579264" // This version must exactly match the version of the NDK that the recipe pulls from CIPD. + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/pure_android_host_apps/android_host_app_v2_embedding/app/build.gradle b/dev/integration_tests/pure_android_host_apps/android_host_app_v2_embedding/app/build.gradle index 71abced98b..fee774a0c7 100644 --- a/dev/integration_tests/pure_android_host_apps/android_host_app_v2_embedding/app/build.gradle +++ b/dev/integration_tests/pure_android_host_apps/android_host_app_v2_embedding/app/build.gradle @@ -8,6 +8,15 @@ android { namespace = "io.flutter.add2app" compileSdk 34 + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = "26.3.11579264" // This version must exactly match the version of the NDK that the recipe pulls from CIPD. + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/pure_android_host_apps/host_app_kotlin_gradle_dsl/app/build.gradle.kts b/dev/integration_tests/pure_android_host_apps/host_app_kotlin_gradle_dsl/app/build.gradle.kts index 80fc8488e9..d7189b8355 100644 --- a/dev/integration_tests/pure_android_host_apps/host_app_kotlin_gradle_dsl/app/build.gradle.kts +++ b/dev/integration_tests/pure_android_host_apps/host_app_kotlin_gradle_dsl/app/build.gradle.kts @@ -7,6 +7,15 @@ android { namespace = "com.example.myapplication" compileSdk = 34 + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + val systemNdkPath: String? = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = "26.3.11579264" // This version must exactly match the version of the NDK that the recipe pulls from CIPD. + ndkPath = systemNdkPath + } + defaultConfig { applicationId = "com.example.myapplication" minSdk = 24 diff --git a/dev/integration_tests/release_smoke_test/android/app/build.gradle b/dev/integration_tests/release_smoke_test/android/app/build.gradle index 357e24908a..526a60cf47 100644 --- a/dev/integration_tests/release_smoke_test/android/app/build.gradle +++ b/dev/integration_tests/release_smoke_test/android/app/build.gradle @@ -30,6 +30,15 @@ android { namespace = "com.example.release_smoke_test" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/spell_check/android/app/build.gradle b/dev/integration_tests/spell_check/android/app/build.gradle index 40d896e873..242e3d7360 100644 --- a/dev/integration_tests/spell_check/android/app/build.gradle +++ b/dev/integration_tests/spell_check/android/app/build.gradle @@ -29,7 +29,15 @@ if (flutterVersionName == null) { android { namespace "com.example.spell_check" compileSdk flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/integration_tests/ui/android/app/build.gradle b/dev/integration_tests/ui/android/app/build.gradle index 0b7c795741..b661791560 100644 --- a/dev/integration_tests/ui/android/app/build.gradle +++ b/dev/integration_tests/ui/android/app/build.gradle @@ -12,6 +12,15 @@ android { namespace "com.yourcompany.integration_ui" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/manual_tests/android/app/build.gradle b/dev/manual_tests/android/app/build.gradle index 8321f807a8..7ae76f585d 100644 --- a/dev/manual_tests/android/app/build.gradle +++ b/dev/manual_tests/android/app/build.gradle @@ -30,6 +30,15 @@ android { namespace = "dev.flutter.manual_tests" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/dev/tracing_tests/android/app/build.gradle b/dev/tracing_tests/android/app/build.gradle index a3bd4a16a4..438f04ee24 100644 --- a/dev/tracing_tests/android/app/build.gradle +++ b/dev/tracing_tests/android/app/build.gradle @@ -30,6 +30,15 @@ android { namespace = "com.example.tracing_tests" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/examples/flutter_view/android/app/build.gradle b/examples/flutter_view/android/app/build.gradle index 7c18e6456f..1feb5a505b 100644 --- a/examples/flutter_view/android/app/build.gradle +++ b/examples/flutter_view/android/app/build.gradle @@ -11,6 +11,15 @@ android { namespace "com.example.view" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/examples/hello_world/android/app/build.gradle.kts b/examples/hello_world/android/app/build.gradle.kts index 175e23095a..d0e5ec689c 100644 --- a/examples/hello_world/android/app/build.gradle.kts +++ b/examples/hello_world/android/app/build.gradle.kts @@ -11,6 +11,15 @@ android { namespace = "io.flutter.examples.hello_world" compileSdk = flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + val systemNdkPath: String? = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/examples/image_list/android/app/build.gradle b/examples/image_list/android/app/build.gradle index e4b8b76b39..1adead8eb0 100644 --- a/examples/image_list/android/app/build.gradle +++ b/examples/image_list/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace "com.example.image_list" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/examples/layers/android/app/build.gradle b/examples/layers/android/app/build.gradle index 87d5fd2ee6..3cb9dd323c 100644 --- a/examples/layers/android/app/build.gradle +++ b/examples/layers/android/app/build.gradle @@ -11,6 +11,15 @@ android { namespace "io.flutter.examples.Layers" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/examples/platform_channel/android/app/build.gradle b/examples/platform_channel/android/app/build.gradle index 6da008a41b..762775b520 100644 --- a/examples/platform_channel/android/app/build.gradle +++ b/examples/platform_channel/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace "com.example.platformchannel" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/examples/platform_view/android/app/build.gradle b/examples/platform_view/android/app/build.gradle index 2fda0ca212..b66e071395 100644 --- a/examples/platform_view/android/app/build.gradle +++ b/examples/platform_view/android/app/build.gradle @@ -29,6 +29,15 @@ android { namespace "io.flutter.examples.platform_view" compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 diff --git a/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt b/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt new file mode 100644 index 0000000000..ae7354f572 --- /dev/null +++ b/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt @@ -0,0 +1,3 @@ +# Empty file to trick the Android Gradle Plugin to download the NDK. This is because AGP requires +# the NDK in order to strip debug symbols from native libraries, does not download it in that case +# (instead, AGP only downloads it when AGP thinks it needs the NDK to build a native library). diff --git a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy index dfec35b704..e9ef058072 100644 --- a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy +++ b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy @@ -62,7 +62,7 @@ class FlutterExtension { * Chosen as default version of the AGP version below as found in * https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp. */ - public final String ndkVersion = "26.1.10909125" + public final String ndkVersion = "26.3.11579264" /** * Specifies the relative directory to the Flutter project directory. @@ -279,6 +279,7 @@ class FlutterPlugin implements Plugin { extension.flutterVersionName = flutterVersionName ?: "1.0" this.addFlutterTasks(project) + forceNdkDownload(project, flutterRootPath) // By default, assembling APKs generates fat APKs if multiple platforms are passed. // Configuring split per ABI allows to generate separate APKs for each abi. @@ -859,6 +860,36 @@ class FlutterPlugin implements Plugin { return version2 } + private void forceNdkDownload(Project gradleProject, String flutterSdkRootPath) { + // If the project is already configuring a native build, we don't need to do anything. + Boolean forcingNotRequired = gradleProject.android.externalNativeBuild.cmake.path != null + if (forcingNotRequired) { + return + } + + // Otherwise, point to an empty CMakeLists.txt, and ignore associated warnings. + gradleProject.android { + externalNativeBuild { + cmake { + // Respect the existing configuration if it exists - the NDK will already be + // downloaded in this case. + path = flutterSdkRootPath + "/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt" + } + } + + defaultConfig { + externalNativeBuild { + cmake { + // CMake will print warnings when you try to build an empty project. + // These arguments silence the warnings - our project is intentionally + // empty. + arguments("-Wno-dev", "--no-warn-unused-cli") + } + } + } + } + } + /** Prints error message and fix for any plugin compileSdkVersion or ndkVersion that are higher than the project. */ private void detectLowCompileSdkVersionOrNdkVersion() { project.afterEvaluate { diff --git a/packages/integration_test/example/android/app/build.gradle b/packages/integration_test/example/android/app/build.gradle index 782992d712..62d30ab06b 100644 --- a/packages/integration_test/example/android/app/build.gradle +++ b/packages/integration_test/example/android/app/build.gradle @@ -26,12 +26,18 @@ if (flutterVersionName == null) { } android { - // Conditional for compatibility with AGP <4.2. - if (project.android.hasProperty("namespace")) { - namespace 'com.example.integration_test_example' - } + namespace 'com.example.integration_test_example' compileSdk flutter.compileSdkVersion + // Flutter's CI installs the NDK at a non-standard path. + // This non-standard structure is initially created by + // https://github.com/flutter/engine/blob/3.27.0/tools/android_sdk/create_cipd_packages.sh. + String systemNdkPath = System.getenv("ANDROID_NDK_PATH") + if (systemNdkPath != null) { + ndkVersion = flutter.ndkVersion + ndkPath = systemNdkPath + } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8