Success Apk built with Codemagic does not work with Firebase

415 Views Asked by At

I have successfully created a build with Codemagic of an Android Flutter app that uses Firebase Google Sign In and Cloud Firestore. I'm only working with Android (not IOS). The google-services.json from Firebase is used in the build of the apk with Codemagic. I'm not publishing, only creating build. The problem is that the app runs perfectly with flutter run (on VSCode), but with the apk build from Codemagic I can't log in / fetch data from Cloud Firestore.

After debugging with Android Studio the error is as follows:

2021-05-13 11:58:08.006 7011-7011/com.luisbarqueira.expenses_control E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
2021-05-13 11:58:29.297 7011-7475/com.luisbarqueira.expenses_control E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(network_error, com.google.android.gms.common.api.ApiException: 7: , null, null)
    #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581:7)
    #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
    <asynchronous suspension>
    #2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:358:43)
    <asynchronous suspension>
1

There are 1 best solutions below

3
On

This could be, because you don't added permission for internet on android. In debug mode this is enabled by default, but on release mode (apk), you have to add the following lines in your AndroidManifest.xml:

<manifest xmlns:android...>
 ...
 <uses-permission android:name="android.permission.INTERNET" />
 <application ...
</manifest>

Reference on flutter.dev