2

Seeing as how there are no preprocessor directives (without jumping through some hurdles), I was wondering if there was an accepted way of doing the following:

  1. Have an android app in the regular ol' android market that uses things like the camera, mic, etc.
  2. Conditionally "swap out" certain features based on some build parameter.
  3. Produce two APKs, one for each store

Ideally, I would want to keep the ANT gymnastics to a minimum ... and also ideally would not have to maintain two sets of files (ie. google_activity_layout.xml and amazon_activity_layout.xml).

edit: this answer looks interesting: https://stackoverflow.com/a/1813873/5416

Community
  • 1
  • 1
Joel Martinez
  • 46,929
  • 26
  • 130
  • 185
  • I have been able to use XMLTask antlib to modify the AndroidManifest.xml as part of the -pre-build hook. I haven't used the mechanism you linked, but I would think that a combination of modifying the permissions and using the linked mechanism would achieve your goal. Since the permissions are checked at runtime vs. at compile time. – Nick Campion Feb 07 '12 at 15:21
  • The XMLTask lib is here http://www.oopsconsultancy.com/software/xmltask/ – Nick Campion Feb 07 '12 at 15:24
  • that's useful, thanks ... why don't you post it as an answer so I can vote it up? ;-) – Joel Martinez Feb 07 '12 at 15:57

1 Answers1

2

I have been able to use XMLTask antlib to modify the AndroidManifest.xml as part of the -pre-build hook. I haven't used the mechanism you linked, but I would think that a combination of modifying the permissions and using the linked mechanism would achieve your goal. Since the permissions are checked at runtime vs. at compile time.

You can find the library here: http://www.oopsconsultancy.com/software/xmltask/

One thing to note, it will take some tinkering. My "ant monkey business" did take several hours of tinkering because of the way the apk is compiled together. If you are willing to run the full build a few times it should be less arduous and could probably just ad a completely new task to the beginning of the build.xml that is generated. Let me know if you have questions as I've been tinkering with this stuff a lot.

Nick Campion
  • 10,479
  • 3
  • 44
  • 58