[英]Gradle: project depends on libraries but is not a library itself
I have android solution that contains 3 projects: 我有包含3个项目的android解决方案:
App depends on domain. 应用取决于域。 Domain depends on data. 域取决于数据。
Here is build.gradle of the app project: 这是应用程序项目的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "com.company.name"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
signingConfigs {
debug {
...
}
}
buildTypes {
...
}
}
dependencies {
compile project(':domain')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.asne.facebook:facebook:3.17.2'
compile 'com.google.android.gms:play-services:6.1.11'
compile 'com.android.support:appcompat-v7:21.0.0'
}
build.gradle of the domain project: 域项目的build.gradle:
apply plugin: 'java'
dependencies {
compile project(':data')
}
build.gradle of the data project: 数据项目的build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "com.company.name"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
...
}
}
dependencies {
compile 'org.simpleframework:simple-xml:2.7.1'
}
The probles is that I get an error and the message of this error that domain layer depends on libraries but is not a library itself
. 问题是我得到一个错误,并且此错误的消息是域层depends on libraries but is not a library itself
。 What's wrong there? 怎么了
My advice would be to remove the dependency of Domain on Data. 我的建议是删除域对数据的依赖。 Instead, inject the data provider into domain. 而是将数据提供程序注入域。 There is a nice article that gives a clue on how different application parts should be related to make unit testing painless. 有一篇很好的文章提供了线索,说明如何使不同的应用程序部分相关联,以使单元测试轻松自如。
The alternative would be to follow @frederick nyawaya's answer and use this tutorial to set up unit testing with Robolectric. 另一种选择是遵循@frederick nyawaya的回答,并使用本教程来设置Robolectric的单元测试。
在你的build.gradle 域 ,添加: apply plugin: 'com.android.library'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.