I was trying to make my already existing app as a base code for my other targets (applications) that i wanted to release. It took me some time in learning the process. I did that and i want to help people by answering it myself. Its straight forward in iOS and seemed rough in android studio , but eventually turned to be insanely simple.
Problem Statement:
Go to the Project toolbar in android studio.
Select Android
view
You will see Gradle Script
in the tree
Their you will find two build script
files, one with Project name and another with module name.
Say for example module name is app (which by default is) double click on it
You will see apply plugin: 'com.android.application'
change it to apply plugin: 'com.android.library'
Gradle Sync your project.
Also remove the ` applicationId "core.example.something" tag from it , Sync again.
Now right click on the project and add new module, You will see a window with different modules select Phone AND tablet (in my case) and follow the on screen instructions.
A new module will be added to your project structure.
Copy paste the android manifest from the app module into this new module.
Check the Gradle Script
tree, you will find a new entry in it, open it and add compile project(":lib") in the dependency (replace lib by app in my case or the module name that you changed into library)
Now go back to the android manifest file of newly added module. see for errors (more of them are gone by now)and add the new package name that you want to release this code as. keep adding modules :D