开关GCM客户端的开发与生产 [英] Switch GCM Client on Development and Production

查看:150
本文介绍了开关GCM客户端的开发与生产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚实施新的GCM。对于正式文件,

Just implement the new GCM. For official document,

复制您刚刚下载到你的Andr​​oid Studio项目的应用程序/或移动/目录下的谷歌,services.json文件。

Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project.

任何人都知道的设置如何摇篮切换开发和生产使用不同的谷歌,services.json?

Anyone know how to setup gradle to switch development and production to use different google-services.json?

推荐答案

我刚才此处回答过类似的问题不同的 productFlavors

在你的情况下,它的调试/生产。我不知道为什么你需要制作和调试之间切换,但我认为你可以做一样的东西,我提议为风味。

In your case it's debug/production. I don't know why you need to switch between production and debug but i think you can do the same as what I proposed for flavors.

创建两个额外的文件夹的src /发布的src /调试,在每一个你把相应的文件夹谷歌services.json ,所以你将有:的src /发行/谷歌services.json 的src /调试/谷歌services.json

Create two extra folders src/release and src/debug , in each of the folders you put the corresponding google-services.json , so you will have: src/release/google-services.json and src/debug/google-services.json

现在在摇篮补充一点:

android {

// set build config here to get the right gcm configuration.
//def myBuildConfig = "release"
def myBuildConfig = "debug"

// this will copy the right google-services.json file to app/ directory.
if (myBuildConfig.equals("release")) {
    println "--> release copy!"
    copy {
        from 'src/release/'
        include '*.json'
        into '.'
    }
} else {
    println "--> debug copy!"
    copy {
        from 'src/debug/'
        include '*.json'
        into '.'
    }
}

// other stuff
}

这篇关于开关GCM客户端的开发与生产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆