How to configure android map sdk v2 to use different keys for production and development?

前端 未结 3 1560
情歌与酒
情歌与酒 2020-12-09 10:35

I want to automatically set different android map api V2 keys for development and production.

3条回答
  •  执笔经年
    2020-12-09 10:58

    One of the easiest solution.You can achieve it with two simple steps.

    Add custom value to manifestplaceholders build.gradle file. See below

    buildTypes {
        debug {
            manifestPlaceholders = [ mapApiKeyValue:"GHjaSyAjlyp3O831lgaonHMXsd-_DpQ3002x3S4"]
        }
    
        release {
            manifestPlaceholders = [ mapApiKeyValue:"AIzaSyAuMGDLr2HeuRed4JA0CrdYYdZRjeC3EA"]
        }
    }
    

    Edit manifest file like below. part of my manifest file

     
    

    This solution works for the latest Android 5.0 and Android 6.0 (API 20, 21,22,23)

提交回复
热议问题