问题描述
我已经使用 Codemagic 成功创建了一个使用 Firebase Google Sign In 和 Cloud Firestore 的 Android Flutter 应用程序的构建。我m only working with Android (not IOS). The google-services.json from Firebase is used in the build of the apk with Codemagic. I
不发布,只创建构建。
问题是该应用程序与 Flutter run(在 VsCode 上)完美运行,但使用 Codemagic 的 apk 构建我无法登录/来自 Cloud Firestore 的 fecth 数据。
使用Android Studio调试后报错如下:
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>
你能帮我解决这个问题吗?
谢谢你,最好的问候, 路易斯
解决方法
这可能是因为您没有在 android 上添加互联网权限。在调试模式下这是默认启用的,但在发布模式 (apk) 中,您必须在 AndroidManifest.xml 中添加以下几行:
<manifest xmlns:android...>
...
<uses-permission android:name="android.permission.INTERNET" />
<application ...
</manifest>