Can I somehow alias R in Android?

I have two Android apps that share 90% of the code with each other, and for political reasons (I think also for technical reasons) you need to have separate package names (so that they appear under different URLs on Google Play)

I use git with two branches for each application, and I synchronize two branches manually before each version. When I run the diff command from two branches, many of my files differ from each other, when in fact the only thing that differs is the package name of the automatically generated R file, so for the first application I have 15 files with

import pkg.name.one.R;

and for another application

import pkg.name.two.R;

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

I tried wrapping R like this:

pack the scene;

public class RWrapper {

    public class R extends pkg.name.one.R {}

}

( RWrapper R), , , R ( , )

, - R , import pkg.name.one.R; / import pkg.name.two.R; ?

, :)

+5
2

RWrapper, R ? R RWrapper.RClass...

public class RWrapper
{
  public static pkg.name.one.R R;
}

public class RWrapper
{
  public static pkg.name.two.R R;
}

R- :

RWrapper.R.<blah>
0

seggy , R.class . , R , - .

package the.submodule.package;

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

. R , ..

0

All Articles