Created
July 27, 2020 15:53
-
-
Save iamEtornam/622891f2501208cf987d65f0ed5664f5 to your computer and use it in GitHub Desktop.
Include both 32bit and 64bit arm libflutter.so files into your APK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def localProperties = new Properties() | |
def localPropertiesFile = rootProject.file('local.properties') | |
if (localPropertiesFile.exists()) { | |
localPropertiesFile.withReader('UTF-8') { reader -> | |
localProperties.load(reader) | |
} | |
} | |
def keystorePropertiesFile = rootProject.file("keystore.properties") //signing key | |
def keystoreProperties = new Properties() | |
keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) | |
def flutterRoot = localProperties.getProperty('flutter.sdk') | |
if (flutterRoot == null) { | |
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties 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: 'com.android.application' | |
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | |
android { | |
signingConfigs { | |
release { | |
keyAlias keystoreProperties['keyAlias'] | |
keyPassword keystoreProperties['keyPassword'] | |
storeFile file(keystoreProperties['storeFile']) | |
storePassword keystoreProperties['storePassword'] | |
} | |
} | |
compileSdkVersion 28 | |
lintOptions { | |
disable 'InvalidPackage' | |
} | |
defaultConfig { | |
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | |
applicationId "dev.etornam.app" | |
minSdkVersion 21 | |
targetSdkVersion 28 | |
versionCode flutterVersionCode.toInteger() | |
versionName flutterVersionName | |
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | |
signingConfig signingConfigs.release | |
} | |
buildTypes { | |
release { | |
minifyEnabled true | |
shrinkResources true | |
proguardFiles getDefaultProguardFile( | |
'proguard-android-optimize.txt'), | |
'proguard-rules.pro' | |
// TODO: Add your own signing config for the release build. | |
// Signing with the debug keys for now, so `flutter run --release` works. | |
signingConfig signingConfigs.release | |
ndk { | |
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64', 'x86' //includes all these | |
} | |
} | |
} | |
} | |
flutter { | |
source '../..' | |
} | |
dependencies { | |
testImplementation 'junit:junit:4.12' | |
androidTestImplementation 'androidx.test:runner:1.2.0' | |
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | |
implementation 'com.google.firebase:firebase-messaging:20.2.1' | |
} | |
apply plugin: 'io.fabric' | |
apply plugin: 'com.google.gms.google-services' | |
// Include both 32bit and 64bit arm libflutter.so files into your APK | |
project.afterEvaluate { | |
assembleRelease.doLast { | |
String src | |
if(project.hasProperty('target-platform') && | |
project.property('target-platform') == 'android-arm64') { | |
// If we are building the 64bit then we also want to add the 32bit libflutter.so | |
src = "$flutterRoot/bin/cache/artifacts/engine/android-arm-release/flutter.jar" | |
}else{ | |
// If we are building the opposite (32bit), we include the 64bit libflutter.so | |
src = "$flutterRoot/bin/cache/artifacts/engine/android-arm64-release/flutter.jar" | |
} | |
copy { | |
from zipTree(src) | |
include 'lib/*/libflutter.so' | |
into "$buildDir/intermediates/jniLibs/release/0/" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment