Ebad Saghar
Ebad Saghar

Reputation: 1127

How to include app dependency to Android studio project?

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.

Upvotes: 0

Views: 337

Answers (1)

Dodd10x
Dodd10x

Reputation: 3349

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

Upvotes: 1

Related Questions