0

Currently I have one Android application "com.mysite.MyApp" in the Eclipse. I need to make two apps ("com.mysite.App1" and "com.mysite.App2") from sources of "com.mysite.MyApp", depending on some "configuration" class constants. I need to do it in the Eclipse, or, using the apache ant.

kruz05
  • 501
  • 1
  • 9
  • 17

1 Answers1

2

Turn com.mysite.MyApp into a library project containing all the common code, and have two separate app projects for App1 and App2 which refer to it.

Graham Borland
  • 60,055
  • 21
  • 138
  • 179
  • Hmm, not an easy way ;) There is no ways in java to make code reusable on source level, like in C/C++? And there is no ways to make project configurations like in Visual Studio (or like targets in makefile)? – kruz05 Sep 27 '12 at 14:46
  • Also, many of my classes uses resources, which are the same for both apps. If I make library, resources can be added to it, not to app? Or how I reffer to app resources from library project? I need to remove all of hard-coded resource ids from code and modify my classes to get them from params (in constrctors etc)? – kruz05 Sep 27 '12 at 14:54
  • Because you want to alter the package name in the manifest (not just Java source), it's much cleaner just to use separate projects. You can do it with Ant trickery, but it's more difficult. – Graham Borland Sep 27 '12 at 14:59
  • You can use resources from a library project just as normal (`R.id.whatever`), it really is quite easy. – Graham Borland Sep 27 '12 at 15:00