我正在开发一个有两个按钮的父android项目。我还有两个android子项目。单击Parent项目的每个按钮都应该打开其中一个Child项目。我在网上搜索,发现我可以通过将Child项目作为库并将它们包含在Parent(作为库)中来组合所有三个项目。我使用this链接在库中转换了两个子项目。转换后,我正在关注this视频,将子库添加到父android项目中。但是,Gradle Sync失败并出现以下错误:
Error: Project :app declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :libraries:ChildProject2
此错误是由build.gradle(父项目)中的以下行引起的:
compile project(':libraries:ChildProject2')
我是android新手,不知道如何解决这个问题。我已经尝试了下面的链接,但是,我无法解决问题。任何帮助将不胜感激。
link:https://discuss.gradle.org/t/dependencies-failing-to-resolve-due-to-configuration-dependencies/1617
settings.gradle
include ':app'
include ':libraries:ChildProject2'
的build.gradle:
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.smartfarmer.parentproject"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile project(':libraries:ChildProject2')//, configuration: "compile")
}