在Flutter中成功创建具有Firebase的新用户后,Android应用程序崩溃

时间:2019-12-09 13:26:57

标签: android firebase flutter firebase-authentication

每当我尝试使用firebase_auth软件包发送使用电子邮件和密码创建新用户时,我的应用程序崩溃。它成功创建了帐户,但随后应用崩溃。我在build.gradle文件中将'com.google.gms:google-services:4.2.0'更改为3.2.1,但这没有帮助。问题仍然存在,我不知道要更改什么。

错误: https://pastebin.ubuntu.com/p/fbzC3dNkv8/

我的代码: https://pastebin.ubuntu.com/p/5Ghjp2Hw55/

我的Flutter Doctor输出

[√] Flutter (Channel stable, v1.9.1+hotfix.6, on Microsoft Windows [Version 6.3.9600], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[!] VS Code (version 1.39.2)
    X Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

我的build.gradle文件: https://pastebin.ubuntu.com/p/t6MPZ5z34M/

我的应用程序级别build.gradle文件: https://pastebin.ubuntu.com/p/tzztfQ4Nhb/

1 个答案:

答案 0 :(得分:0)

我解决了这个问题。我这样更改了gradle.properties文件:

android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx1536M

我的应用程序级别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 = '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"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.cagriserpin.focus_on"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    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
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'androidx.multidex:multidex:2.0.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
}

apply plugin: 'com.google.gms.google-services'

希望对遇到此问题的其他人有所帮助