Reputation: 497
When I execute flutter run
my app works fine with Firebase (cloud_firestore) but whenever I do one of these commands:
flutter build apk --release
or
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
my app does not work properly with cloud_firestore. It doesn't do CRUD operations.
pubspec.yaml (plugins):
google_sign_in: 4.5.1
firebase_auth: 0.16.1
firebase_core: ^0.4.0+8
firebase_analytics: ^5.0.14
cloud_firestore: ^0.13.6
app/build.gradle:
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 = '15'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '15.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.tomeruby.iusefully"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
// ndk {
// abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a'
// }
}
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.release
multiDexEnabled true
}
}
}
flutter {
source '../..'
}
dependencies {
// implementation 'com.google.firebase:firebase-core:16.0.5'
// implementation 'com.google.firebase:firebase-analytics-impl:16.2.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
If you need more information, please let me know. Thanks in advance :D
Upvotes: 1
Views: 1820
Reputation: 2165
try changing
classpath 'com.google.gms:google-services:4.3.0'
in your project gradle.build to
classpath 'com.google.gms:google-services:3.2.1'
and in gradle.properties add
android.useAndroidX=true
android.enableJetifier=true
Upvotes: 2