I have a library project called toolkit with two modules core
and database
, with this config:
settings.gradle
include ':core'
include ':database'
core build.gradle
dependencies {
compile 'com.android.support:support-v4:20.+'
compile 'com.jakewharton:butterknife:5.1.+'
compile 'com.google.code.gson:gson:2.2.+'
compile 'uk.co.chrisjenx:calligraphy:0.7.+'
compile files('libs/flurry-3.4.0.jar')
}
database build.gradle
dependencies {
compile project(':core')
}
it`s ok when run my tests at this library project, but i want add this library as a git submodule on other project, this project have the follow configuration:
settings.gradle
include ':app-tablet'
include 'libraries:float-hint'
include 'libraries:toolkit:core'
include 'libraries:toolkit:database'
include 'libraries:twoway-view:TwoWayView'
app build.gradle
dependencies {
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.google.android.gms:play-services:+'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.jayway.android.robotium:robotium-solo:5.2.1@jar'
compile 'com.squareup.dagger:dagger:1.2.+'
compile 'com.squareup.picasso:picasso:2.1.1@jar'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile project(':libraries:float-hint')
compile project(':libraries:porquenao-toolkit:core')
compile project(':libraries:porquenao-toolkit:database')
compile project(':libraries:twoway-view:TwoWayView')
}
and when I try compile i get the follow:
$ gradlew assembleDebug -d
12:10:46.283 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
12:10:46.285 [ERROR] [org.gradle.BuildExceptionReporter]
12:10:46.285 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
12:10:46.285 [ERROR] [org.gradle.BuildExceptionReporter] Build file '/path/libraries/toolkit/database/build.gradle' line: 16
12:10:46.286 [ERROR] [org.gradle.BuildExceptionReporter]
12:10:46.286 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
12:10:46.286 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating project ':libraries:toolkit:database'.
12:10:46.287 [ERROR] [org.gradle.BuildExceptionReporter] > Project with path ':core' could not be found in project ':libraries:toolkit:database'.
12:10:46.308 [ERROR] [org.gradle.BuildExceptionReporter] ... more
12:10:46.308 [LIFECYCLE] [org.gradle.BuildResultLogger]
12:10:46.308 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
I know the problem is about paths :core
and libraries:toolkit:core
but how solve this appropriately?
You have a naming issue your apps gradle files.
The settings.gradle has:
include 'libraries:toolkit:core'
And the build.gradle has:
compile project(':libraries:porquenao-toolkit:core')
Assuming you fix this up, you will still have an error.
The database module will be trying to compile ":core", but when used in the app, the core module has a different path: ":libraries:porquenao-toolkit:core"
One way to work around this is to include the core library as ":core" in both projects, but give it a different project path.
Your settings.gradle files would look like:
Toolkit:
include ':core'
project(':core').projectDir = new File(rootDir, 'core')
App:
include ':core'
project(':core').projectDir = new File(rootDir, 'libraries/porquenao-toolkit/core')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With