繁体   English   中英

将 android 工作室的 google-service.json 更改为 firebase_option.dart 项目项目 Z5ACEBC4CB70DDBBAEZB0AC76AAB176

[英]Change google-service.json from android studio to firebase_option.dart on flutter project

我有一个 android 工作室项目,该项目使用 google-service.json 文件链接到 firebase,但我不允许访问该 ZBFA12E1515FC415C7。 我只知道 google-service.json 内容。
现在我想构建一个具有 firebase_option.dart 文件的 flutter 项目。 我可以将该 google-service.json 文件链接到我的项目吗? 或者我需要改变什么才能让它工作?

编辑:
I tried changing the apiKey , appId , ... from the original file to the flutter file, then copy the google-services.json file and put it in the android folder of the flutter project but it didn't work.
另一个问题是 FirebaseOptions ios具有 iosClientIdiosBundleId等字段,我不知道如何替换它。 你能找到帮助我的方法吗?

没有自动转换,但您可以手动转换值。

Flutter 端需要的是这样的:

await Firebase.initializeApp(
  options: FirebaseOptions(
    apiKey: 'AI...PM',
    appId: '1:10...7f4',
    messagingSenderId: '10...957',
    projectId: 'yourprojectid',
    storageBucket: 'yourprojectid.appspot.com',
  )
);

因此,从该代码开始,然后在您的google-services.json中找到最可能的值并将其插入。 如果您在制作特定密钥时遇到问题,请回复您尝试过的内容,我们可以看看。


针对获取 iOS 特定值的新问题进行编辑:您无法从 Android 特定google-services.json文件中获取 iOS 应用程序的配置数据。 为此,您需要GoogleService-info.plist文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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