I want to attach different string resources files during android ant release and debug builds. I need this to have separate configuration for map api key, remote host etc
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
I use Eclipse for day to day debug builds, then Ant for release builds. I have debug and release versions of the file holding the Google Maps API key. I've modified the build.xml (I'm on SDK tools R15) to do some copying of the appropriate file before the build and afterwards. I've changed the -pre-build and release targets like so:
I define layout.dir in the ant.properties (new name for build.properties post SDK Tools 14) file:
You could adapt this to suit your needs, assuming you don't have too many files to swap in and out. I guess you could add a property for the directory holding your strings.xml
Nick, I don't understand why you also rewrite release task. I've added prebuild only and it works for me
The two answers are all based on
Eclipse ADT
. NowAndroid Studio
is the more popular IDE, you can take advantage ofgradle
build system.In your
build.gradle
file, add the following code inandroid
tag:You can use
BuildConfig.LOG_DEBUG
as aboolean
value in your Java code. Just remember toimport your.package.name.BuildConfig;
You can also use
some_key
as a string resource. The Java code of using it is:R.string.some_key
.