android - 从本地文件系统加载 google-services.json

标签 android firebase gradle android-gradle-plugin

google-services.json Firebase Android plugin 使用的文件通常放在应用程序的模块文件夹中。

我想要做的是将这个文件完全放在项目文件夹之外的文件系统上的某个位置,然后让 gradle/Firebase 插件从那里读取它。

我想把它的位置放在 local.properties并以某种方式“告诉”Firebase 插件以获取 google-services.json 的位置从那里。
我怎样才能做到这一点?

最佳答案

根据offical documentation , google-services.json文件一般放在app/ directory (位于 Android Studio 应用模块的根目录)。从 2.2.0 版开始,插件支持构建类型和产品 flavor 特定的 JSON 文件。以下所有目录结构均有效:

// dogfood and release are build types.
app/
    google-services.json
    src/dogfood/google-services.json
    src/release/google-services.json
    ...

Note: Providing a google-services.json file in the release directory allows you to maintain a separate Firebase project for your production APKs. When product flavors are in use these more complicated directory structures are also valid.


// free and paid are product flavors.
app/
    google-services.json
    src/dogfood/paid/google-services.json
    src/release/free/google-services.json
    ...

作为结论,您不能添加 google-services.json项目之外的文件。

希望能帮助到你。

关于android - 从本地文件系统加载 google-services.json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46444371/

相关文章:

java - 如何向创建的 GSON 添加属性到 JSON?

ios - Tableview 中的 Swift Firebase Firestore 数据

android - 在 Firebase 中制作 POJO 时,可以使用 ServerValue.TIMESTAMP 吗?

java - Gradle说我的Java安装在错误的位置,尽管它找到了正确的文件夹

Android Studio/Gradle 构建找不到自定义应用程序类

spring - 可以在 Spring 上下文中使用gradle替换值吗?

Android 抛出带有 LOG : Transaction failed on small parcel; remote process probably died 的 DeadObjectException

android - 什么是 USB 接口(interface)子类 66?

android - 将原始 PCM 位保存到压缩音频 AAC/AMR 文件中

ios - 表的Firebase查询