There are numerous examples showing how to get the package name in code at runtime.
In my case, I need to test the package name at compile time.
Here is my situation: I have two Android projects (the free and the pro) which leverage a library project.
The free version has a “Get the pro version” menu item, which does not exist in the other version.
My menu handling code goes like this:
if ( item.getItemId()==R.id.getProVersion ) {
//...
}
Proguard complains that R.id.getProversion does not exist when building the pro package.
So I need to test which project is being built, to exclude this part of the code from being compiled.
Is there a way to know the package name at compile time ?
Are there alterative solutions to this problem ? Either Android-centered or java-centered solutions are fine.
You can put the menu item in the library project, and then use the runtime package name checks to actually decide whether to display the message or not