Can I somehow alias R in Android?

I have two Android applications that share 90% of their code with each other, and due to political reasons (I think also technical reasons) need to have separate package names (so they'll appear under different URLs in Google Play)

I use git with two branches for each app, and I sync the two branches manually before each release. When running a diff command of the two branches, a lot of my files are different when in reality the only thing that's different is the package name of the auto generated file R, so for the first application I have 15 files with


and for the other app


I want to somehow import R in the same way for both classes.

I tried wrapping R like so:

package thescene;

public class RWrapper {

    public class R extends {}


(which would make RWrapper the only different file between these two branches in regards to the source or R) but alas R is a final class (and I'm not even sure this would've worked anyway)

So it there a way to somehow alias the R class in a way that would allow me to have the import; / import; replaced with a unified import statement?

I'm also open to other suggestions that would solve my syncing woes :)


Couldn't you modify RWrapper to make R a static field instead of a class? Your code would then access R via RWrapper.RClass...


public class RWrapper
  public static R;


public class RWrapper
  public static R;

You'd access the R fields with:


seggy had it almost right, but you need to expose each R.class individually. If the sub-module has it's own namespace then you can re-use the class name R and not need to modify anything in your sub-module.

package the.submodule.package;

public final class R {
public static string;
public static drawable;
public static id;
//public static the.local.appPackage.R.anythingElse anythingElse;

Note: I'm not condoning sharing R across projects, but sometimes time constraints etc.

Need Your Help

How to generate a URL for ASP.NET MVC without string names

How to generate a URL for ASP.NET MVC without string names? I.e. I have Index action in HomeController. Using strings I would go for

Mathematical modulus in c#

c# modulo

Is there a library function in c# for the mathematical modulus of a number - by this I specifically mean that a negative integer modulo a positive integer should yield a positive result.