0

I may be using the wrong terminology for what I am really asking. But let me describe what I need.

I have two separate apps, one was made first and the second was made later, but the second app has files that I have copy+pasted over from the first app. Now, there are separate apps and projects. But I was wondering if there is a way to to have 1 project but with 2 apps in it and be able to build/compile them as separate apps? This is so that I wouldn't need to have multiple copies of the same Java code in 2 separate places. I want to have the second app dependent on the first one, so that if I were to make a change I wouldn't need to make a change in multiple places.

I've googled and search for my problem, but I get solutions for including/adding 3rd party libraries and dependencies (which I already know how to do), but that's not what I need.

EDIT: I would need them to generate 2 separate APK files.

Ebad Saghar
  • 1,107
  • 2
  • 16
  • 41
  • The build system of Android is Gradle, and it is flexible. Check this [question.](http://stackoverflow.com/questions/17536652/gradle-and-multi-project-structure) It will give you a hint. – makata Sep 16 '15 at 19:34
  • @makata - I would need them to generate 2 separate APK files – Ebad Saghar Sep 16 '15 at 20:20

1 Answers1

1

Since you seem to not want to create your first project as a library, you could set up symbolic links from your second app to the source code of your first. They would remain two projects, and the second would link to the source code in the first.

Any shared code you changed in one, would be reflected in the other.

I'm assuming you are using Windows, so check this link out.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365680(v=vs.85).aspx

OSX Link: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man7/symlink.7.html

As requested. GIT can save the value of symbolic links. With some configuration it can follow them if that's what's needed. Also, you could use a branch in git to accomplish the separation of projects with a shared branch.

How does git handle symbolic links?

Links on branches:

https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches http://git-scm.com/docs/git-branch

Community
  • 1
  • 1
Dodd10x
  • 3,344
  • 1
  • 18
  • 27
  • Actually, I am using Mac. But a team member of mine is using Windows. – Ebad Saghar Sep 16 '15 at 20:16
  • Also, I need them to generate 2 separate APK files. – Ebad Saghar Sep 16 '15 at 20:20
  • You would still have two projects in Android Studio. The first project would be your original project. The other would be your second project that has symbolic links to the source/resource files needed from your first. You could still generate two APKs. – Dodd10x Sep 16 '15 at 20:31
  • Thanks for the edit and providing the OSX link as well. Also, symbolic link would work, only problem is that every team member would have to create a symbolic link on their own environment (unless I'm wrong). Is there anyay other than symbolic links to provide what I need without forcing each dev environment to create the links individually? – Ebad Saghar Sep 16 '15 at 21:20
  • How is your team all accessing the same code as it it right now? At some point you need replication across the team members. – Dodd10x Sep 16 '15 at 23:43
  • through git/bitbucket. That is my point exactly, using symbolic links won't help us, I don't think, since we will all have to apply the symbolic links across all dev environments. Right? – Ebad Saghar Sep 17 '15 at 07:01
  • GIT can store symbolic links. But if you are using version control why don't you create a branch? https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging – Dodd10x Sep 17 '15 at 15:38
  • I didn't know GIT can store symbolic links. Please provide that in your answer so I can select it as the answer to my question. Thank you. – Ebad Saghar Sep 17 '15 at 18:18
  • Updates complete as requested – Dodd10x Sep 17 '15 at 18:58