Skip to content

Commit

Permalink
chore: support build as a flutter module (#70)
Browse files Browse the repository at this point in the history
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

superlistapp/super_native_extensions#379

---------

Co-authored-by: Ji Fang <[email protected]>
  • Loading branch information
jifang and Ji Fang authored Jun 11, 2024
1 parent 969c49a commit d56f1f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test_example_plugin_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion gradle/plugin.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ class CargoKitPlugin implements Plugin<Project> {
}

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

Expand Down

0 comments on commit d56f1f2

Please sign in to comment.