Android - use ant to create build configurations that change configuration values

前端 未结 4 1451
春和景丽
春和景丽 2020-12-05 01:19

What I want is a way to have settings that are dependent on build configuration. To give a specific example, my android application connects to a web service. In developme

4条回答
  •  不知归路
    2020-12-05 02:04

    You could try to have a following property file in your build.properties file:

    service.url=*
    

    And you could have http://localhost:1234 or https://test.mydomain.com in local.properties for your development and integration testing, and it could be set to https://mydomain.com in default.properties.

    By do ing this, you have will get different value for service.url in different build environment. You could use that value to generate a config file, and parse it into your code, or set it to env variable, or just put it into a resource file, and Android will read it for you:

    
    
        @@toben_to_be_replaced_during_build_time@@
    
    

提交回复
热议问题