I am working on creating an Android SDK module that includes a Flutter module. I have followed the instructions provided in the official Flutter documentation here to integrate the Flutter module into my Android project.
setBinding(new Binding([gradle: this])) evaluate(new File( settingsDir.parentFile, // new 'flutter_module/.android/include_flutter.groovy' // new )) // new I have also added the Flutter module as a dependency in my app/build.gradle file within my Android module.
implementation project(':flutter') I have successfully integrated the Flutter module with a method channel, and it's working as expected.
Now, my challenge is in creating an AAR artifact library that includes the complete Flutter modules. When I generate the AAR artifact using the following Gradle code snippet, the sub-modules are not included in the library:
group = 'com.example.myAndroidSdk' version = '1.0.0' // Add sources as an artifact task sourceJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier "source" } // Loop over all variants android.libraryVariants.all { variant -> variant.outputs.all { output -> // This creates a publication for each variant publishing.publications.create(variant.name, MavenPublication) { // The sources artifact from earlier artifact sourceJar // Variant dependent artifact, e.g. release, debug artifact source: output.outputFile, classifier: output.name // Go through all the dependencies for each variant and add them to the POM // file as dependencies pom.withXml { def dependencies = asNode().appendNode('dependencies') // Filter out anything that's not an external dependency. You shouldn't // be publishing artifacts that depend on local (e.g. project) dependencies, // but who knows... configurations.getByName(variant.name + "CompileClasspath").allDependencies .findAll { it instanceof ExternalDependency } .each { def dependency = dependencies.appendNode('dependency') dependency.appendNode('groupId', it.group) dependency.appendNode('artifactId', it.name) dependency.appendNode('version', it.version) } } } } } // Ensure that the publish task depends on assembly tasks.all { task -> if (task instanceof AbstractPublishToMaven) { task.dependsOn assemble } } How can I ensure that the complete Flutter modules are included in my Android AAR artifact? What modifications or additional steps do I need to take?
flutter build aar. Possibly related: github.com/flutter/flutter/issues/39707