0

I'm using Flutter in Visual Studio Code and Android Studio with a Pixel 6a emulator with Android 13 to preview the app.

Despite I could connect to other services of Firebase (Authentication, Storage, App Check), when arriving to Firestore, I have a certificate error that I'm not being able to solve :

enter image description here

After searching, I've read I would need to use an Android Emulator with Google Play services active to be able to have the correct certificates and also that only Android 13 and 14 are stable enough to have these certificates integrated in the image. So I've changed my emulator, previously a Pixel 6 with Android 16 and Google APIs, to a Pixel 6a with Android 13 and Google Play Services.

When I was working with Storage service of Firebase this seemed to solve the SSL problem, but now that I've started with Firestore, the problem appeared again.

I've already generated a self signed certificate, put it in assets/certs and in res/raw of the project, created a network_security_config.xml in res/xml, with the content :

<network-security-config>
    <domain-config>
        <domain includeSubdomains="true">com.example.chat_app</domain>
        <trust-anchors>
            <certificates src="@raw/chat_app_certificate_name"/>
        </trust-anchors>
    </domain-config>
</network-security-config>

and pointed to it in my android manifest :

<application
        android:label="chat_app"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:networkSecurityConfig="@xml/network_security_config">

Finally, I've installed this certificate with the private key in the emulator, but the error continue. Moreover, I've tried to install the other certificate I have from android keystore in the emulator but this is not accepted to be installed without a private key.

So, beside trying to create a true certificate from a trusted CA, I'm getting out of options.

Is it really needed al this configuration to connect to Firestore while developing?

2 Answers 2

2

I’ve faced the same issue before, so I tried a few solutions — here are the solutions that worked for me

Solution 1:

  • Use a Play Store–enabled emulator.

  • Use an Android 13 or 14 emulator with Google Play (not just Google APIs).

Solution 2:

  • android/app/src/main/AndroidManifest.xml should contain android:usesCleartextTraffic="true"

Solution 3 (It's working for me):

  • Upgrade your Flutter version and firebase package version
Sign up to request clarification or add additional context in comments.

Comments

0

In the end I've followed all these steps (except the upgrade of version) and I had 2 problems :

- SSL connexion error in Firebase Storage service
- Firestore default database not found in Firestore service

For the first one I**'ve generated a local CA certificate** and I had the corresponding xml and asset configuration as explained in the question above. But this time, beside doing 'flutter clean' and 'flutter pub app get', I also did the 'flutterfire configure' command again.

Then, I've reinstalled the certificate in the emulator again.

The emulator was a Pixel6a with Android 14 and Google Play Services.

For the problem of Firestore, I had to delete all my databases in the console, and create a new one, NOT GIVING IT A NAME (the default name stays as the default). With this my app could finally find the (default) database.

And, not forgetting to add the debug token of this version of the app in the App Check, this time, the 3 services I was testing worked ! Authentication, Storage and Firestore !

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.