tags:

views:

60

answers:

1

Hi: I want to release multiple applications to android marketplace which are all very slightly customized based on a code base. I can't just change the package indentifier in the AndroidManifest.xml file because several other things dependet on this like action identifiers and so on. What is the best approach to release several apps based on one eclipse project with the same code base?

+3  A: 

You need to create a library project and reference it from every of your apps. Latest versions of ADT plugin allow this. Go to the project properties, android page, you'll see a 'library' checkmark there. Reference to the library is also setup on the page.

Konstantin Burov
Thanks for the hint. i already thought about this approach. But what if I have intents in my existing project with actions like org.example.myandroidapp.myaction ? So these actions should be now app specific.
Sney
You have to support manifest for each app (right now activity definitions cannot be shared from library projects). Hence nothing stops you from having different actions (and intent filters) for each app.
Konstantin Burov
Yeah, but how would android know to which app the action call belongs to when they share the same name in the library among several apps?
Sney
Probably I miss something.. can you share a code example on how you use actions/intent filters?
Konstantin Burov
@Konstantin: Sure, here it is: **someIntent.setAction("org.example.myapp.MY_ACTION");**
Sney
So if that code is in library project, you just need to form the action string based on you app package name: someIntent.setAction(getPackageName()+"MY_ACTION"); getPackageName() will return different string for each of your apps; then you just need to have appropriate intent filter in each AndroidManifest.xml.
Konstantin Burov
That solution quite elegant. Another issue is how to use the resource class 'R'. If I refer **R.drawable.icon** in the library with the drawable being in a dependent application that won't work. Is there some way to achieve this? Or do I really have to override the concerning library classes in my depending application?
Sney
Well you can place the icon into your library project and refer it as R.drawable.icon. Then if you need to override the resource in the end app you just should place a resource with same name in app res/drawable folder. ADT will then just pick up end up resource instead of that in library.
Konstantin Burov