Skip to content

Instantly share code, notes, and snippets.

Created May 7, 2019 11:44
Show Gist options
  • Save SPodjasek/0a93fed9ca038169c5afe962f10a5d18 to your computer and use it in GitHub Desktop.
Save SPodjasek/0a93fed9ca038169c5afe962f10a5d18 to your computer and use it in GitHub Desktop.
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the file.")
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
apply plugin: ''
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystorePropertiesFile = rootProject.file("")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
defaultConfig {
// TODO: Specify your own unique Application ID (
applicationId "xxx"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner ""
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
flutter {
source '../..'
afterEvaluate {
mergeReleaseJniLibFolders.doLast {
def archTypes = ["arm-release", "arm64-release"]
archTypes.forEach { item ->
copy {
from zipTree("$flutterRoot/bin/cache/artifacts/engine/android-$item/flutter.jar")
include 'lib/*/'
into "$buildDir/intermediates/jniLibs/release/"
eachFile {
it.path = it.path.replaceFirst("lib/", "")
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation ""
implementation ""
testImplementation 'junit:junit:4.12'
androidTestImplementation ''
androidTestImplementation ''
apply plugin: ''
Copy link

Hi @SPodjasek, thanks for sharing the file. Mine, for the most part, looks identical.
Here is my flutter doctor

[✓] Flutter (Channel dev, v1.5.8, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Android Studio (version 3.4)
[!] VS Code (version 1.33.1)
    ✗ Flutter extension not installed; install from
[✓] Connected device (1 available)

I wonder what is your flutter build command? I have tried the following:

  • flutter clean; flutter build appbundle on my computer still omit arm64-v8a/
  • flutter clean; flutter build apk same result
  • flutter clean; flutter build apk --target-platform=android-arm64 will have the opposite effect (armeabi-v7a/ is missing)

Here is my intermediates directory which looks absolutely fine.

Copy link

I use flutter build appbundle and it always include proper libs in output build/app/outputs/bundle/release/app.aab.

Can you switch flutter to beta channel and check there?

Copy link

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not get unknown property 'mergeReleaseJniLibFolders' for project ':app' of type org.gradle.api.Project.

Copy link

minh98 commented Jun 22, 2019

worked for me with flutter build appbundle. Thanks :D

Copy link

  • What went wrong:
    A problem occurred evaluating project ':app'.

Could not find method fterEvaluate() for arguments [build_8a95qgiavjx0ev0fdlftv5rhy$_run_closure4@c9821b4] on project ':app' of type

what went wrong

Copy link

IMHO There's no need to use this custom app_build.gradle anymore as proper multi-arch support has landed in mainline flutter...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment