0

My goal is to create multiple android APKs. All that is different is the package name and I manually override some things in the res folder.

I understand you can do a library project. The problem with that is we have to manage multiple manifest files and the version with that. That is not what I want to do.

I was looking into aapt to create the new package name and shared res folder. The problem is I do not know where to start. I see lots of examples like: Custom Android build.xml for rename manifest package also below is exactly what I want to do: http://blog.uncommons.org/2010/07/19/building-two-versions-of-the-same-android-app/

Can anyone provide direction on where to start?

Community
  • 1
  • 1
David Corrado
  • 363
  • 3
  • 19

2 Answers2

2

The best way to do this is to create a library project, and than create separate projects for each of the APKs that you want to have. Each APK project can than have its own Manifest and reference the Library Project. Believe me when I tell you that this is much easier than trying to rename packages during build/compile time. You can easily call into activities that are shared in the library package just as long as you use the fully qualified name in the individual APK's manifest file.

http://developer.android.com/tools/projects/projects-eclipse.html

javram
  • 2,635
  • 1
  • 13
  • 18
  • Here is a good article that states the different types of android projects and when/why you should use them http://developer.android.com/tools/projects/index.html – javram Jan 15 '13 at 22:16
  • This approach makes sense to me. Create a library to contain your core code, then create simple projects that for each of the APKs you want to create. – Booger Jan 15 '13 at 22:18
  • Yes it makes sense but the problem is as I mentioned in my post is that library projects require you if there is an update in the library that you create that you update each project version and do a build which sounds too tedious. I am doing 16 apps all with just different resources generally. I am looking for how to do this with just with a script that changes the package name and adds the shared res folder. – David Corrado Jan 15 '13 at 22:26
  • You can have a resource folder for each of the apps with resources that are specific to that application, as well as a resource folder in the library package. If you are changing something that is specific to one of the apps, than you only have to rebuild that app, if you are changing something that is in the library, than yes, you would need to build/sign multiple apks, but you can automate that if you want with a tool like nant. – javram Jan 15 '13 at 23:00
  • With how my application is setup generally the projects will never change. The bulk of the code is in the library. So I would have to every time I would build update the version 16 times manually in the code. Unless you know of a way to automate that. Also you make a change in the manifest file you have to put those changes in each of the projects. It does not sound like doing a library project will work well for me which is why I would like to do aapt – David Corrado Jan 15 '13 at 23:16
  • Check out this blog post. Use ant to build your apks, so you can avoid the manual part of building. http://www.androidengineer.com/2010/06/using-ant-to-automate-building-android.html good luck – javram Jan 15 '13 at 23:19
  • So you explained to me how to automate building. But not how to automate with libraries keeping your manifest file in sync with the library except the package name. I do not think this is possible without some ugly code with dynamically creating the manifest file. Do you know anything about creating the APKs via aapt so I do not have to manage these other projects. – David Corrado Jan 15 '13 at 23:27
  • Sorry, I am not sure what you mean. You would have a manifest file for the Library project and a separate manifest file for each APK. I am not sure why you would need to sync them? Do you anticipate adding new activities on a regular basis, or changing the permissions that the application needs? – javram Jan 16 '13 at 00:50
  • I would need to ensure the manifests are the same. So it is kind of annoying to have to update 16 manifest files for every update. Also I definitely would have to update versions every time. I think there is an easier process to do this. If I just use some script to loop through all the apps. Change the package name of the manifest and point to the additional resources and build. It sounds to me like a much simpler process. – David Corrado Jan 16 '13 at 16:26
  • There is a reason why google added so you can update the package name in the manifest:https://android-review.googlesource.com/#/c/32670/ – David Corrado Jan 16 '13 at 16:31
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/22858/discussion-between-javram-and-david-corrado) – javram Jan 16 '13 at 19:58
0

I had the same problem before and made a batch file to copy files like images, mp3 files, etc. to the workspace folder where I have my application folder in it. You have to make everything dynamic if you don't want to use the library project. I hope this helps, else you can ask me anything you want.

Aerial
  • 1,185
  • 4
  • 20
  • 42
  • I am trying to avoid trying to hack something together. It seems aapt has built in to do what I am looking for I am just looking for an example of how to do this. – David Corrado Jan 15 '13 at 22:28
  • Ahh ok, let me know what you did in order to solve your problem. I'm curious, that's all. :) – Aerial Jan 15 '13 at 22:47