I am trying to import my own library into one of my apps in Android Studio. I have seen instructions in several places that basically amount to :
1 Move the files into a library folder within your project diectory.
2 Add include 'projectName:folderName:libraryName
to your settings.gradle file
3 Add compile project('folderName:libraryName')
under dependencies to your project level build.gradle file
This works for me if I am importing a module... I think its a module. I'm still trying to figure out gradle. My library structure looks like this:
ProjectName
Module1
Classes
Module2
Classes2
If I import Module1 or Module2 separately in this fashion (where Module1 is my 'libraryName' in the instructions above), they will work. But if I try to import the whole project as one library I get errors.
What am I doing wrong? I would like to import the entire project as I would like it to have many modules. Is there another/better way to do this? What am I misunderstanding?
Update:
As per @ScottBarta 's instructions I merged settings.gradle files. This appears to have worked in my main project because the gradle sync completed properly but I'm not ready to run that project. So I made a tester project and imported the library using the same steps. This time I get the error:
Gradle 'Tester' project refresh failed:
Build script error, unsupported Gradle DSL method found. 'compile()'!
As near as I can tell, the files are equivalent in the two projects:
Main:
include ':Eed'
include ':Eed:libraries:Overt:Visible'
include ':Eed:libraries:Overt:Control'
Test:
include ':app'
include ':app:libraries:Overt:Visible'
include ':app:libraries:Overt:Control'
Main:
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project('libraries:Overt:Visible')
compile project('libraries:Overt:Control')
}
Test
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
complie project('libraries:Overt:Visible')
complie project('libraries:Overt:Control')
}
And here's a screenshot of the file structure in the Tester project.