【发布时间】:2020-08-16 14:32:50
【问题描述】:
我在 Visual Studio 2019 中有一个 Xamarin Forms 解决方案。我现在只使用 Android 版本。完整的错误是:
Java.Lang.IllegalStateException Message=默认 FirebaseApp 不是 在这个过程中初始化appcardview.sample.android。确保 首先调用 FirebaseApp.initializeApp(Context)。
在我的 Android 项目中,我正在尝试连接到 Firebase 身份验证。我已经添加了我的 google-services.json。我在网上看到应该添加为:
<ItemGroup>
<GoogleServicesJson Include="google-services.json" />
</ItemGroup>
但这给了我一个错误,告诉我 GoogleServicesJson 无法识别,所以我将它添加到我的 .csproj 文件中
<ItemGroup>
<None Include="google-services.json" />
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
<None Include="Properties\AndroidManifest.xml" />
</ItemGroup>
1-我还在android项目的MainActivity类的onCreate方法的开头添加了以下行;我已将它添加到我的 onCreate 的开头,也许我需要将它放在其他地方?:
FirebaseApp.InitializeApp(Application.Context);
2-问题可能是我在 .csproj 文件中添加它的方式吗?
3-有人还提到了以下内容,我不确定这意味着什么或我应该改变什么,也许这就是问题所在?
确保您的包名与包名相同 在“google-services.json”中
【问题讨论】:
标签: c# firebase xamarin xamarin.forms firebase-authentication