medihack
medihack

Reputation: 16627

Add (external) local library project as dependency in Android Studio

I am trying to add a local library project that I cloned (and modified a bit) from Github (Android-ReactiveLocation) as a dependency to my application.

According to this answer it should be as easy as:

settings.gradle

include(':reactivelocation')
project(':reactivelocation').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation')

build.gradle in my app directory

dependencies {
  ...
  compile project(':reactivelocation')
}

Unfortunately I get the error

Error:Configuration with name 'default' not found.

As soon as I add the compile statement. What am I doing wrong?

I also tried to use compile project(':reactivelocation:android-reactive-location') as I am only interested in this module library inside Android-ReactiveLocation, but this also fails

Project with path ':reactivelocation:android-reactive-location' could not be found in project.

Update. Some other things I tried without success (same error):

settings.gradle

include(':android-reactive-location')
project(':android-reactive-location').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation/android-reactive-location')

build.gradle in my app diretory

dependencies {
  ...
  compile project(':android-reactive-location')
}

settings.gradle

include(':Android-ReactiveLocation')
project(':Android-ReactiveLocation').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation')

build.gradle in my app diretory

dependencies {
  ...
  compile project(':Android-ReactiveLocation')
}

settings.gradle

include(':Android-ReactiveLocation:android-reactive-location')
project(':Android-ReactiveLocation:android-reactive-location').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation/') // also with '../Andrdoid-ReactiveLocation/android-reactive-location'

build.gradle in my app diretory

dependencies {
  ...
  compile project(':Android-ReactiveLocation:android-reactive-location')
}

Upvotes: 0

Views: 1054

Answers (2)

swalog
swalog

Reputation: 4536

A bit late to the party here. But, are you aware that the directory you listed in the settings, might have a typo?

include(':reactivelocation')
project(':reactivelocation').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation')
                                                                    ^^^^^^^^

Perhaps this should be, as the project you have cloned named, Android-ReactiveLocation

Upvotes: 0

Misagh Emamverdi
Misagh Emamverdi

Reputation: 3674

I have a similar scenario in my project. In build.gradle in app directory you should add path before the library name:

compile project(path: ':reactivelocation')

In my project every things work whit above line. My settings.gradle is exactly like yours.

Upvotes: 1

Related Questions