From d56f1f269efeb7a7b2919dc7d8302ef6bddf47f0 Mon Sep 17 00:00:00 2001 From: Ji Fang Date: Tue, 11 Jun 2024 16:11:25 +0800 Subject: [PATCH] chore: support build as a flutter module (#70) When build as a flutter module and integrated into the existing android project, there is no applicationVariants and result in following compilation failure: Could not get unknown property 'applicationVariants' for extension 'android' of type com.android.build.gradle.LibraryExtension. In such case, we will use libraryVariants instead https://github.com/superlistapp/super_native_extensions/issues/379 --------- Co-authored-by: Ji Fang --- .github/workflows/test_example_plugin_build.yml | 6 +++++- gradle/plugin.gradle | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_example_plugin_build.yml b/.github/workflows/test_example_plugin_build.yml index bf36e8628..4fb0252dc 100644 --- a/.github/workflows/test_example_plugin_build.yml +++ b/.github/workflows/test_example_plugin_build.yml @@ -77,6 +77,10 @@ jobs: shell: bash working-directory: ${{ env.EXAMPLE_DIR }} run: | - export JAVA_HOME=$JAVA_HOME_11_X64 + if [[ $(sysctl hw.optional.arm64) == *"hw.optional.arm64: 1"* ]]; then + export JAVA_HOME=$JAVA_HOME_17_arm64 + else + export JAVA_HOME=$JAVA_HOME_11_X64 + fi flutter build apk --${{ matrix.build_mode }} -v diff --git a/gradle/plugin.gradle b/gradle/plugin.gradle index 12c49f110..37dd086af 100644 --- a/gradle/plugin.gradle +++ b/gradle/plugin.gradle @@ -116,8 +116,12 @@ class CargoKitPlugin implements Plugin { } def cargoBuildDir = "${project.buildDir}/build" + + // Determine if the project is an application or library + def isApplication = plugin.project.plugins.hasPlugin('com.android.application') + def variants = isApplication ? plugin.project.android.applicationVariants : plugin.project.android.libraryVariants - plugin.project.android.applicationVariants.all { variant -> + variants.all { variant -> final buildType = variant.buildType.name