Created
June 21, 2022 10:23
-
-
Save cyb3rsalih/c34ac3b6b2b725293db9a0c02397164d to your computer and use it in GitHub Desktop.
Android App for Release (Flutter)
This file contains 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
// You should have ../key.properties , and ../app.keystore file | |
def localProperties = new Properties() | |
def localPropertiesFile = rootProject.file('local.properties') | |
if (localPropertiesFile.exists()) { | |
localPropertiesFile.withReader('UTF-8') { reader -> | |
localProperties.load(reader) | |
} | |
} | |
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 plugin: 'kotlin-android' | |
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | |
// IMPORTANT PART - 1 | |
def keystoreProperties = new Properties() | |
def keystorePropertiesFile = rootProject.file('key.properties') | |
if (keystorePropertiesFile.exists()) { | |
keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) | |
} | |
// End of IMPORTANT PART - 1 | |
android { | |
compileSdkVersion 31 | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 | |
targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
kotlinOptions { | |
jvmTarget = '1.8' | |
} | |
sourceSets { | |
main.java.srcDirs += 'src/main/kotlin' | |
} | |
defaultConfig { | |
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | |
applicationId "com.example.app" | |
minSdkVersion 20 | |
targetSdkVersion 31 | |
versionCode flutterVersionCode.toInteger() | |
versionName flutterVersionName | |
multiDexEnabled true | |
} | |
// IMPORTANT PART - 2 | |
signingConfigs { | |
release { | |
keyAlias keystoreProperties['keyAlias'] | |
keyPassword keystoreProperties['keyPassword'] | |
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null | |
storePassword keystoreProperties['storePassword'] | |
} | |
} | |
buildTypes { | |
release { | |
// TODO: Add your own signing config for the release build. | |
// Signing with the debug keys for now, so `flutter run --release` works. | |
//signingConfig signingConfigs.debug | |
signingConfig signingConfigs.release | |
proguardFiles getDefaultProguardFile( | |
'proguard-android-optimize.txt'), | |
'proguard-rules.pro' | |
} | |
} | |
// End of IMPORTANT PART - 2 | |
} | |
flutter { | |
source '../..' | |
} | |
dependencies { | |
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | |
implementation "com.jakewharton.threetenabp:threetenabp:1.2.3" | |
implementation platform('com.google.firebase:firebase-bom:28.4.2') | |
implementation 'com.google.firebase:firebase-analytics-ktx:1.1.15' | |
testImplementation 'junit:junit:4.12' | |
androidTestImplementation 'androidx.test:runner:1.2.0' | |
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment