Pergunta

So I'm building an application with a dev, test and release version. I have additional fragments in the dev and test version which I don't want to show up in the release version. Currently hide those fragments in the actionbar and prevent the user from swiping to different fragments (thereby preventing them from going to the hidden fragments).

I have a final static variable which I set to dev, test or release which then builds the app with/without the tabs. Can I make it somehow that it doesn't even compile those fragments in the release version? I know I could possibly recreate 3 projects with the differences in them but I was looking for just one copy of the source code so I don’t have to keep track of changes in the core app.

Foi útil?

Solução

If the fragments are totally unused in some builds, you can use the ProGuard tool to remove them from the APK.

Outras dicas

Yes this can be done, all you need to do is to use Gradle based new build system.

One goal of the new build system is to enable creating different versions of the same application.

There are two main use cases:

  1. Different versions of the same application For instance, a free/demo version vs the “pro” paid application.

  2. Same application packaged differently for multi-apk in Google Play Store. See http://developer.android.com/google/play/publishing/multiple-apks.html for more information.

  3. A combination of 1. and 2.

More detail here http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top