Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a linked source folder in Android Studio?

In Eclipse I can add a source folder to my android project as a "linked source folder". How do I achieve the same thing in Android Studio?

Or is it possible to add a external folder to build in gradle?

like image 789
Erik Z Avatar asked Sep 22 '13 18:09

Erik Z


People also ask

How do I create a folder in Android Studio?

In the drop down menu click on the new option. After this a drop down menu opens here you will see directory option just click on that. After this enter the name of your directory / folder and press enter this will create a new folder / directory inside your root folder.

What is resource folder in Android?

The res/values folder is used to store the values for the resources that are used in many Android projects to include features of color, styles, dimensions etc.


2 Answers

in your build.gradle add the following to the end of the android node

android {     ....     ....      sourceSets {         main.java.srcDirs += 'src/main/<YOUR DIRECTORY>'     }  } 
like image 65
fabrizotus Avatar answered Oct 02 '22 11:10

fabrizotus


The right answer is:

android {     ....     ....      sourceSets {         main.java.srcDirs += 'src/main/<YOUR DIRECTORY>'     } } 

Furthermore, if your external source directory is not under src/main, you could use a relative path like this:

sourceSets {     main.java.srcDirs += 'src/main/../../../<YOUR DIRECTORY>' } 
like image 45
lyfshadyboss Avatar answered Oct 02 '22 12:10

lyfshadyboss