Skip to content

Commit

Permalink
chore: support build as a flutter module
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
  • Loading branch information
Ji Fang committed May 29, 2024
1 parent 969c49a commit 9b80608
Showing 1 changed file with 5 additions and 1 deletion.
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 9b80608

Please sign in to comment.