This is from my blog post that describes how to build a free / paid version using a library project.
Generally, you'll create three projects; a free project, a paid project and a library project.
You'll then create a Build.java file in your library project such as this:
public class Build {
public final static int FREE = 1;
public final static int PAID = 2;
public static int getBuild(Context context){
return context.getResources().getInteger(R.integer.build);
}
}
Now, you'll create an build.xml resource in each of your projects:
[library]/resources/values/build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<integer name="build">0</integer>
</resources>
[free]/resources/values/build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<integer name="build">1</integer>
</resources>
[paid]/resources/values/build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<integer name="build">2</integer>
</resources>
You will then be able to check for the version at run time:
if (Build.getBuild(context) == Build.FREE){
// Do the free stuff
} else {
// Do the paid stuff
}
The blog post details the exact steps necessary to create the projects from scratch at the Linux command line.