@@ -1032,6 +1032,15 @@ class FlutterPlugin implements Plugin<Project> {
10321032                    }
10331033                }
10341034            }
1035+             //  Build an AAR when this property is defined.
1036+             boolean  isBuildingAar =  project. hasProperty(' is-plugin'  )
1037+             //  In add to app scenarios, a Gradle project contains a `:flutter` and `:app` project.
1038+             //  `:flutter` is used as a subproject when these tasks exists and the build isn't building an AAR.
1039+             Task  packageAssets =  project. tasks. findByPath(" :flutter:package${ variant.name.capitalize()}  Assets"  )
1040+             Task  cleanPackageAssets =  project. tasks. findByPath(" :flutter:cleanPackage${ variant.name.capitalize()}  Assets"  )
1041+             boolean  isUsedAsSubproject =  packageAssets &&  cleanPackageAssets &&  ! isBuildingAar
1042+             boolean  isAndroidLibraryValue =  isBuildingAar ||  isUsedAsSubproject
1043+ 
10351044            String  variantBuildMode =  buildModeFor(variant. buildType)
10361045            String  taskName =  toCamelCase([" compile"  , FLUTTER_BUILD_PREFIX , variant. name])
10371046            //  Be careful when configuring task below, Groovy has bizarre
@@ -1044,6 +1053,7 @@ class FlutterPlugin implements Plugin<Project> {
10441053                flutterRoot this . flutterRoot
10451054                flutterExecutable this . flutterExecutable
10461055                buildMode variantBuildMode
1056+                 minSdkVersion variant. mergedFlavor. minSdkVersion. apiLevel
10471057                localEngine this . localEngine
10481058                localEngineHost this . localEngineHost
10491059                localEngineSrcPath this . localEngineSrcPath
@@ -1068,6 +1078,7 @@ class FlutterPlugin implements Plugin<Project> {
10681078                codeSizeDirectory codeSizeDirectoryValue
10691079                deferredComponents deferredComponentsValue
10701080                validateDeferredComponents validateDeferredComponentsValue
1081+                 isAndroidLibrary isAndroidLibraryValue
10711082                doLast {
10721083                    project. exec {
10731084                        if  (Os . isFamily(Os . FAMILY_WINDOWS )) {
@@ -1097,13 +1108,6 @@ class FlutterPlugin implements Plugin<Project> {
10971108            addApiDependencies(project, variant. name, project. files {
10981109                packFlutterAppAotTask
10991110            })
1100-             //  We build an AAR when this property is defined.
1101-             boolean  isBuildingAar =  project. hasProperty(' is-plugin'  )
1102-             //  In add to app scenarios, a Gradle project contains a `:flutter` and `:app` project.
1103-             //  We know that `:flutter` is used as a subproject when these tasks exists and we aren't building an AAR.
1104-             Task  packageAssets =  project. tasks. findByPath(" :flutter:package${ variant.name.capitalize()}  Assets"  )
1105-             Task  cleanPackageAssets =  project. tasks. findByPath(" :flutter:cleanPackage${ variant.name.capitalize()}  Assets"  )
1106-             boolean  isUsedAsSubproject =  packageAssets &&  cleanPackageAssets &&  ! isBuildingAar
11071111            Task  copyFlutterAssetsTask =  project. tasks. create(
11081112                name : " copyFlutterAssets${ variant.name.capitalize()} "  ,
11091113                type : Copy ,
@@ -1194,6 +1198,9 @@ class FlutterPlugin implements Plugin<Project> {
11941198                        }
11951199                    }
11961200                }
1201+                 //  Copy the native assets created by build.dart and placed here by flutter assemble.
1202+                 def  nativeAssetsDir =  " ${ project.buildDir}  /../native_assets/android/jniLibs/lib/" 
1203+                 project. android. sourceSets. main. jniLibs. srcDir nativeAssetsDir
11971204            }
11981205            configurePlugins()
11991206            detectLowCompileSdkVersionOrNdkVersion()
@@ -1219,7 +1226,7 @@ class FlutterPlugin implements Plugin<Project> {
12191226                    //  | ----------------- | ----------------------------- |
12201227                    //  |   Build Variant   |   Flutter Equivalent Variant  |
12211228                    //  | ----------------- | ----------------------------- |
1222-                     //  |   freeRelease     |   release                       |
1229+                     //  |   freeRelease     |   release                     |
12231230                    //  |   freeDebug       |   debug                       |
12241231                    //  |   freeDevelop     |   debug                       |
12251232                    //  |   profile         |   profile                     |
@@ -1277,6 +1284,8 @@ abstract class BaseFlutterTask extends DefaultTask {
12771284    File  flutterExecutable
12781285    @Input 
12791286    String  buildMode
1287+     @Input 
1288+     int  minSdkVersion
12801289    @Optional  @Input 
12811290    String  localEngine
12821291    @Optional  @Input 
@@ -1325,6 +1334,8 @@ abstract class BaseFlutterTask extends DefaultTask {
13251334    Boolean  deferredComponents
13261335    @Optional  @Input 
13271336    Boolean  validateDeferredComponents
1337+     @Optional  @Input 
1338+     Boolean  isAndroidLibrary
13281339
13291340    @OutputFiles 
13301341    FileCollection  getDependenciesFiles () {
@@ -1414,6 +1425,11 @@ abstract class BaseFlutterTask extends DefaultTask {
14141425            if  (extraFrontEndOptions !=  null ) {
14151426                args " --ExtraFrontEndOptions=${ extraFrontEndOptions} " 
14161427            }
1428+             args " -dAndroidArchs=${ targetPlatformValues.join(' ')} " 
1429+             args " -dMinSdkVersion=${ minSdkVersion} " 
1430+             if  (isAndroidLibrary !=  null ) {
1431+                 args " -dIsAndroidLibrary=${ isAndroidLibrary ? "true" : "false"} " 
1432+             }
14171433            args ruleNames
14181434        }
14191435    }
0 commit comments