Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
How to best maintain two different versions of the same app?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mariano Kamp  
View profile  
 More options Jan 8 2010, 1:15 pm
From: Mariano Kamp <mariano.k...@gmail.com>
Date: Fri, 8 Jan 2010 19:15:08 +0100
Local: Fri, Jan 8 2010 1:15 pm
Subject: How to best maintain two different versions of the same app?

Hi,

this seems to be a very basic need, but googling it I got the impression
that is not easily or elegantly solvable.

The requirement is totally simple: I want to have a lite and pro version of
an app. There is a little bit of difference between those two apps, but they
are 99% identically.
Unfortunately it seems that the best choice is to really treat this as two
projects that are one and the same and copy over the source code and assets
from one to the other. The Android Manifest file must be different, because
the Android Market - for some reason - makes the implementation's package
name the ID.

Working around this ID issue the straight forward approach would be to have
a third project with the common code that exports its code, libraries and in
a best case scenario also the ressources to the other two objects.
Unfortunately this doesn't work. Only the actual Android projects generate
the R.class and so the common project would need to be dependent on it,
which would make it a cycle ;(

Am I thinking too complicated? Do I miss the obvious?

Cheers,
Mariano


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frank Weiss  
View profile  
 More options Jan 8 2010, 1:22 pm
From: Frank Weiss <fewe...@gmail.com>
Date: Fri, 8 Jan 2010 10:22:22 -0800
Local: Fri, Jan 8 2010 1:22 pm
Subject: Re: [android-developers] How to best maintain two different versions of the same app?

I've suggested using Eclipse project dependency, but haven't whether or not
it works for Android projects.

On Jan 8, 2010 10:15 AM, "Mariano Kamp" <mariano.k...@gmail.com> wrote:

Hi,

this seems to be a very basic need, but googling it I got the impression
that is not easily or elegantly solvable.

The requirement is totally simple: I want to have a lite and pro version of
an app. There is a little bit of difference between those two apps, but they
are 99% identically.
Unfortunately it seems that the best choice is to really treat this as two
projects that are one and the same and copy over the source code and assets
from one to the other. The Android Manifest file must be different, because
the Android Market - for some reason - makes the implementation's package
name the ID.

Working around this ID issue the straight forward approach would be to have
a third project with the common code that exports its code, libraries and in
a best case scenario also the ressources to the other two objects.
Unfortunately this doesn't work. Only the actual Android projects generate
the R.class and so the common project would need to be dependent on it,
which would make it a cycle ;(

Am I thinking too complicated? Do I miss the obvious?

Cheers,
Mariano

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com<android-developers%2Bunsubs cribe@googlegroups.com>
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "How to best maintain two different versions of the same app?" by Mark Murphy
Mark Murphy  
View profile  
 More options Jan 8 2010, 1:32 pm
From: Mark Murphy <mmur...@commonsware.com>
Date: Fri, 08 Jan 2010 13:32:41 -0500
Local: Fri, Jan 8 2010 1:32 pm
Subject: Re: [android-developers] How to best maintain two different versions of the same app?

Mariano Kamp wrote:
> Working around this ID issue the straight forward approach would be to
> have a third project with the common code that exports its code,
> libraries and in a best case scenario also the ressources to the other
> two objects. Unfortunately this doesn't work. Only the actual Android
> projects generate the R.class and so the common project would need to be
> dependent on it, which would make it a cycle ;(

That depends on what code you are trying to reuse. I have many projects
that package as JARs for reuse -- they simply don't require access to
the R. stuff. Check my github page (http://github.com/commonsguy) and
look for the cwac- projects.

However, that's not really a practical approach for full-fledged
applications.

> Am I thinking too complicated? Do I miss the obvious?

It is difficult to answer this, since we don't know what the difference
is between the free and not-free versions of your app.

I'm going to assume that the differences could be handled by some sort
of global free/not-free flag. By that, I mean that the same code would
make up both versions of the app, and which portions are enabled or used
would be dependent on some public static data member somewhere:

if (SomeClass.IS_PAID_APP) {
        // add more stuff to menu, etc.

}

If you can organize your app that way, then you only need one code base.
Have it set to build your app one way (free or paid, your choice) and
with the proper package in your manifest for that version of the app.
Then, add an Ant task that does the following:

1. Makes a tree copy of your project dir to a temporary location

2. Switch the copy of the manifest to the new package name via a
search-and-replace

3. Switch all import statements for your old package's edition of R to
the new package, again via search-and-replace, and again on the copy,
not your original

4. Change your IS_PAID_APP (or whatever) to the opposite value
(search-and-replace in the copy)

5. Executes an Ant build for the copy of the project

6. Copies the binaries from that build to the main project's bin/
directory under a distinct name (so it doesn't clobber your other copy
of the APK)

7. Deletes the tree copy made in step #1

As Mr. Weiss points out, Eclipse dependent projects might handle some of
this -- I'm not an Eclipse user, so I cannot say for certain.

If Java had a pre-processor, this would be somewhat simpler. However,
the basic technique that I describe above has been used for a couple of
decades now. It's clunky, but it works, and it means you only have one
set of source code to deal with.

Note that the Ant <replace> task would handle your search-and-replace
stuff nicely.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.3 Available!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Olivier Guilyardi  
View profile  
 More options Jan 8 2010, 1:44 pm
From: Olivier Guilyardi <l...@samalyse.com>
Date: Fri, 08 Jan 2010 19:44:30 +0100
Local: Fri, Jan 8 2010 1:44 pm
Subject: Re: [android-developers] How to best maintain two different versions of the same app?
On 01/08/2010 07:15 PM, Mariano Kamp wrote:

The first thing that comes to my mind is to use svn, develop the pro version in
the trunk, and create a branch for your lite version. Then merge the trunk
changes from time to time into the lite branch.

If you want to simplify merging, then you could also create this third project
you're talking about, but without trying to export any resources (or code that
references them) from it, only generic application model/logic/utilities, etc..

--
  Olivier


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "How to best maintain two different versions of the same app?" by Dan Sherman
Dan Sherman  
View profile  
 More options Jan 8 2010, 1:55 pm
From: Dan Sherman <impact...@gmail.com>
Date: Fri, 8 Jan 2010 13:55:17 -0500
Local: Fri, Jan 8 2010 1:55 pm
Subject: Re: [android-developers] How to best maintain two different versions of the same app?

We had good luck with our latest project with just checking the package
string.  Naming the project xxx.xxxxxxx.project, and xxx.xxxxxx.project_lite

And in our Activity subclass, checking for the package name, and setting a
static variable for paid.

Depends how much code needs to switch with paid/unpaid.  For us, it was only
10-20 lines different, so we just wrapped them in that check.

When going to export both versions, we export one, then change the package
name, recompile, and export the second.  Thats about it...

- Dan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fry  
View profile  
 More options Jan 8 2010, 2:16 pm
From: fry <bender...@gmail.com>
Date: Fri, 8 Jan 2010 11:16:19 -0800 (PST)
Local: Fri, Jan 8 2010 2:16 pm
Subject: Re: How to best maintain two different versions of the same app?
I have spent some time trying to solve the same task in different ways
and at the 1st end came to 2 mostly identical projects variant and at
the 2nd end came to even more simple solution as suggested above - I
have 1 project for both basic and pro versions, and basic version can
become pro version at runtime depending on some constant in the code
(in order to do this had to make difference with basic and pro
versions minimal in order to avoid messing the code) because it was
very hard to maintain 2 similar projects at the same time without
using some kind of advanced tools like git or something like that.

You can have the shared code in the dependency project, but it can
have only basic java code - no activities, shared resources and any
other staff which should use generated R.java. You even will not be
able to load layout.xml file by hands and set it as activity layout at
runtime (if you would try to avoid using R.java with such hack) -
there is API for that, but it thows runtime exception at some moment.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »