简体   繁体   中英

Google play services error firebase in android studio

I am new to firebase and flutter. I was watching a video and I decided to make a reminder app using flutter and firebase, but as soon as I connect the database, the following error comes .

W/GooglePlayServicesUtil(27206): com.learnflutter.firebasee requires the Google Play Store, but it is missing.
E/GooglePlayServicesUtil(27206): GooglePlayServices not available due to error 9
W/Firestore(27206): (23.0.4) [GrpcCallProvider]: Failed to update ssl context: com.google.android.gms.common.GooglePlayServicesNotAvailableException
W/utter.firebase(27206): Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getAlpnSelectedProtocol()[B (greylist-max-q,core-platform-api, reflection, denied)
W/utter.firebase(27206): Accessing hidden method Lcom/android/org/conscrypt/AbstractConscryptSocket;->getAlpnSelectedProtocol()[B (greylist-max-q, reflection, denied)
E/AndroidRuntime(27206): FATAL EXCEPTION: grpc-okhttp-0
E/AndroidRuntime(27206): Process: com.learnflutter.firebasee, PID: 27206
E/AndroidRuntime(27206): java.lang.AssertionError: Method getAlpnSelectedProtocol not supported for object SSL socket over Socket[address=firestore.googleapis.com/142.250.77.42,port=443,localPort=52872]
E/AndroidRuntime(27206):    at io.grpc.okhttp.internal.OptionalMethod.invoke(OptionalMethod.java:114)
E/AndroidRuntime(27206):    at io.grpc.okhttp.internal.OptionalMethod.invokeWithoutCheckedException(OptionalMethod.java:135)
E/AndroidRuntime(27206):    at io.grpc.okhttp.OkHttpProtocolNegotiator$AndroidNegotiator.getSelectedProtocol(OkHttpProtocolNegotiator.java:183)
E/AndroidRuntime(27206):    at io.grpc.okhttp.OkHttpProtocolNegotiator$AndroidNegotiator.negotiate(OkHttpProtocolNegotiator.java:145)
E/AndroidRuntime(27206):    at io.grpc.okhttp.OkHttpTlsUpgrader.upgrade(OkHttpTlsUpgrader.java:63)
E/AndroidRuntime(27206):    at io.grpc.okhttp.OkHttpClientTransport$4.run(OkHttpClientTransport.java:571)
E/AndroidRuntime(27206):    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
E/AndroidRuntime(27206):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(27206):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(27206):    at java.lang.Thread.run(Thread.java:923)
I/Process (27206): Sending signal. PID: 27206 SIG: 9
Lost connection to device.

The following is my pubspec yaml and my build.gradle file:

Build Gradle:

ef 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"
apply plugin: 'com.google.gms.google-services'


android {
    compileSdkVersion 30

    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.learnflutter.firebasee"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        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"
    implementation 'com.google.firebase:firebase-analytics'
    implementation platform('com.google.firebase:firebase-bom:28.4.2')
    implementation 'com.google.android.gms:play-services-location:18.0.0'



}

Pubspec Yaml:

name: firebasee
description: A new Flutter project.


environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter



  cupertino_icons: ^1.0.2
  #Firebase
  firebase_core: ^1.7.0
  firebase_auth: ^3.1.2
  cloud_firestore: ^2.5.3
  add_2_calendar: ^2.1.2
  datetime_picker_formfield: ^2.0.0
  flutter_launcher_icons: ^0.9.2
  flutter_spinkit: ^5.1.0
  pull_to_refresh: ^2.0.0




dev_dependencies:
  flutter_test:
    sdk: flutter

Can someone please help me out? I have been googling the error and trying different things but nothing solves the problem://

您需要在模拟器上下载 Google Play (CH Play) 或使用真实设备代替,因为您在应用中使用的服务需要 Google Play 来处理。

This error happens due to your emulator not supporting google play services. If your using the android studio emulator make sure you create a emulator that support google play APIs. When your choosing an emulator make sure you choose a device that supports the e plays store and choose a system image supporting google play services APIs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM