Multiple Android Application Package .apk files from single source code

后端 未结 10 944
我在风中等你
我在风中等你 2020-12-02 06:29

I would like an Android build system procedure, command line or Eclipse, to generate several .apk files from a single source codebase. Some common reasons for this - having

相关标签:
10条回答
  • 2020-12-02 06:53

    One way to do it would be to maintain two separate AndroidManifest.xml, one for each configuration. You can switch back and forth between the two either manually (copying) or automatically (build script).

    [edit] This person here has a system to do this kind of thing: http://blog.elsdoerfer.name/2010/04/29/android-build-multiple-versions-of-a-project/

    0 讨论(0)
  • 2020-12-02 06:59

    Here's our situation: we have a single codebase from which we release for several clients. Each of them has various requirements regarding titles, backgrounds and other resources in the application (let alone package names).

    Build is handled by a Ruby script that modifies AndroidManifest, copies/replaces certain resources from client-specific folders and then moves on to Android's standart build routine. After the build is done, script resets changed files back to their original, 'default' state.

    Well... Maybe it's not optimal and definitely not Android-specific, but that's how we do it.

    0 讨论(0)
  • 2020-12-02 07:01

    My team build 2 different build using single code base + additional code. As android build is based on ant script, I use ant script to do this work.

    I used xmltask to manipulate manifest xml file and many ant task ( regexp , copy..) to edit source code.

    I prepared template project template ( including build.xml , default.properties, local.properties) and copied new source code into those project templates. when copy completed, run build.xml parallel to shorten build time. when build finished, I get multiple apk files.

    0 讨论(0)
  • 2020-12-02 07:02

    Despite your insistence that this is not about packaging shared code into Android libraries, it sort of is. You've stated that markets may have different requirements or having a free and a paid version. In each of these examples, your two final output APKs have different behavior and/or resources. You can put the vast majority of your code in a shared Android library, and then maintain the differences in your actual projects.

    For example, I've worked on apps where they need to be released both to the Android Market and the Amazon AppStore. The Amazon AppStore requires that if you link to a market page for the app, it must be Amazon's (as opposed to the Android Market page). You can store a URL in a resource in the library and use that in your code, but then override that resource in the Amazon project to point to the appropriate Amazon URL.

    If you structure it right, you can do similar things in code because your starting point is your Application object which you can subclass and do different things with.

    That said, if you want to add an Ant step that changes the package name in the manifest, it is just XML. It shouldn't be hard to modify as a precompilation step.

    0 讨论(0)
  • 2020-12-02 07:04

    I had the same problem but packing all in one project with flags is no solution for me. I wrote an example how to do that with Maven:

    How to create multiple Android apk files from one codebase organized by a Maven multi module project.

    0 讨论(0)
  • 2020-12-02 07:08

    I think that the best way remain to use libray for common sources and two different Android project for demo and production package. This because in Java it is very simple to make a reverse engeneering from apk to sources. If you use the same sources for demo and production, someone could hacking your apk downloading the demo package, extracting the java sources and unlock the sources changing the variable to use it as production version. With library you can preserve part of sources in the production package, in this way there is no way to use demo package as production package.

    0 讨论(0)
提交回复
热议问题