How to handle a cloned service from paid and free app?

by Moto » Sat, 27 Feb 2010 01:39:49 GMT


Sponsored Links
 I would like to make my life easier by having one common code base for
my service for both paid and free apps.  I want to eliminate the
complex merging I find my self doing every time I need to release!

As of now I had to change the service file name along with the Remote
service aidl calls.

Please any advice would be helpful!

-Moto!

--



How to handle a cloned service from paid and free app?

by Frank Weiss » Sat, 27 Feb 2010 02:24:51 GMT


 This is a recurring question. I think it should be added to the Android dev
docs.




I would like to make my life easier by having one common code base for
my service for both paid and free apps.  I want to eliminate the
complex merging I find my self doing every time I need to release!

As of now I had to change the service file name along with the Remote
service aidl calls.

Please any advice would be helpful!

-Moto!

--


Sponsored Links


How to handle a cloned service from paid and free app?

by Moto » Sat, 27 Feb 2010 02:35:55 GMT


 Ok, any recurring answers?




>



How to handle a cloned service from paid and free app?

by Streets Of Boston » Sat, 27 Feb 2010 04:39:28 GMT


 This is not optimal, but this is what i did.

Implement your service, aidl and related java classes in one of your
apps (either the free or the paid one) in your Android project. Make
sure that your service is up to snuff at some point and all runs well.
Be sure to put the aid and all related java classes under one package
name (or sub-packages). This makes it easier to move later.

Create a regular Java project. Use the android.sdk (instead of JDK1.5)
in the library path.
Physically move the package (and sub-packages) of your service code,
your aidl and your related java class, AND the java class generated
from your aidl, from your Android project to this new Java project.

Remove this package (and sub-packages) of your service code from your
Android project (including the java file generated by the aidl under
the 'gen' folder) if they are still there.

In your Android projects, both your paid and free version, link to the
newly created regular Java project that contains the code for your
service.

It works well for me.
However, if i need to make a change in the aidl, it won't re-generated
its java file, since it's no longer part of an Android project. That's
a downside.

In your Android projects subclass the class from your regular Java
project that is the Service. E.g. 'com.me.myapp.free.SomeService
extends MyService' and 'com.me.myapp.paid.SomeService extends
MyService', where 'MyService' is now defined in your regular Java
project. And put the SomeService in your Manifest.




--



How to handle a cloned service from paid and free app?

by Moto » Sat, 27 Feb 2010 04:56:44 GMT


 Hi St. of Boston!

That's great feedback!  It's really nice to know what other developers
are doing!  I'll look into that...

-Moto!





--



How to handle a cloned service from paid and free app?

by Bob Kerns » Sat, 27 Feb 2010 05:53:42 GMT


 hat I've come up with:

* I have *three* versions -- a dev version, and two release versions
(free, pro). This helps keep things straight, and helps ensure that
the release ones are built via a common transformation.

* The dev version is what is checked in, and is what I build and test
via Eclipse.

* The free/pro versions are produced via a master (project-
independent) ant script. This script:

** Determines the build number from the highest Subversion version
number in {project, common tools (including this build script), third-
party (including the SDK))

** Tags the release-to-be via an Subversion copy operation

** Checks out/cleans+updates, so I have a clean working copy of my new
tag. (Doing a clean+copy is faster than a new checkout, but it's just
an optimization).

** I export TWO copies of the working copy, one for FREE, one for PRO

** I perform the necessary transformations on each copy (see below)

** I then invoke the project's build script in each of these two
copies

** I then copy the results to my build repository (both debug and
release versions).

The transformations I've found I need are:

* Via an XSLT script, I change the package name in the manifest,
replacing .dev with .free or .pro
* I set android:debuggable="false"
* I set the android:versionCode and android:versionName attributes

* I set up my project so that I have three packages, each containing
classes with the name named in the manifest:
** com.sfsmart.xxx.dev
** com.sfsmart.xxx.free
** com.sfsmart.xxx.pro

These are mostsly trivial subclasses of a common abstract base class
that provides the base functionality, but I put any code that's
specific to another variant in these classes.

Thus, when I switch the package in the manifest from, say,
com.smfsmart.xxx.dev to com.sfsmart.xxx.pro, it switches classes, and
I don't have to do anything complicated to implement the change.

* I also make some changes to the metadata in the manifest -- changing
somme IDs, etc. that I store there. I could also remove things that
aren't used in one version.

* I run another XSLT script over my resource .xml files. This one
simply substititues the package name in the namespaces of certain
elements. I don't know of any case that needs this except references
to attributes defined in a declare-stylable. I don't know any way to
pin those to a specific package. I thought that aapt's new --custom-
package command-line argument would do it, but it didn't seem to. I
may try that again, though; I may have had a bug in my XSTL script at
the time. But it's only available in the 2.1 version of aapt.

Finally, I have to make one change to my project build script. (I'm
thinking of injecting this via the master!) The one major fly in the
ointment, is that R.java changes packages. My ant script changes its
package and moves it back to com.sfsmart.xxx.dev, where it is in the
development builds. This could be avoided if --custom-package can be
made to work; I plan to look into this further.

The result is that the code doesn't have to change at all. The
resources change very slightly, though I'm looking for a solution
there. Each product runs the exact same .java (but not the same code
paths). The differences are all driven by the manifest changes.

I haven't done it yet, but I plan to make the .dev version launch
either the .free or the .pro version, based on a dev-only setting.
This way, I can ea



How to handle a cloned service from paid and free app?

by Posri » Tue, 02 Mar 2010 22:22:40 GMT


 ou could use a licensing solution like licmax (http://www.licmax.com)
and check the license type at runtime (either dynamically via http or
locally using hashed license key). All the decision for enabled
features is contained within one code base, and there is only one
build of your app necessary.

http://www.licmax.com/developersTab.html

has sample code for Android as well.

HTH

On Feb 26, 1:53pm, Bob Kerns <r...@acm.org> wrote:

--



How to handle a cloned service from paid and free app?

by Posri » Tue, 02 Mar 2010 22:22:47 GMT


 You could use a license solution like licmax ( http://www.licmax.com ).
You just check the license type for your app on that device, and
enable what features you want.  One code base, one build.

HTH




--



Other Threads

1. Camera Portrait

Hi all

I am opening camera from my application...and the orientation of camera is
Landscape... but i actually want it to be portrait ...

im using code from here:

http://snippets.dzone.com/user/Jbeer

any kind of help will do...

Thanks

-- 

2. How to make soft keypad to come out on Setfocus event?

Hi
What I m trying to do is, as soon as user come into that specific
screen/activity, I want to get focus on specific EditText box as well
as the softkey pad will come out without needing to touch on that text
box. Please give me any idea or suggestion to make it happen.
Thank u in advance.

-- 

3. Touch events

4. How does a "held" wakelock impact if the service dies with out releasing it?

5. MSM72xx AOSP port missing hardware audio acceleration

6. findViewbyId returns null --- called in a custom CursorAdapter -- bindView() method. Codes in body.

7. Rumor: HTC Scorpion and all of its 1.5 Ghz, Android 2.2 goodness headed for Verizon?