摇篮同步错误:一个名为“默认”配置未找到 [英] Gradle sync Error:Configuration with name 'default' not found
问题描述
我要添加外部库 GuillotineMenu-的Android 在我的应用程序。我跟着最upvoted答案给现有的问题,<一个步骤href=\"http://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-the-android-studio\">How做我添加一个库项目到Android工作室?
但我面对错误,当我尝试时加入应用程序/的build.gradle
依赖为第6步之后,即建立项目编制项目(:guillotinemenu )
。我尝试了所有与此相关的错误,但它不工作了计算器的链接。我在我的应用程序目录下创建的文件夹命名库和复制的项目文件夹的断头台菜单那里。这是我的
的build.gradle(模块:应用程序)
文件
I want to add an external library GuillotineMenu-Android in my application. I followed the steps given in the most upvoted answer to an existing question How do I add a library project to the Android Studio?
But I am facing error when I try to build project after step 6 i.e. when added dependency in app/build.gradle
as compile project(":guillotinemenu")
. I tried all the stackoverflow links related to this error but its not working out. I have made a folder named libs in my app directory and copied the project folder guillotine menu there. Here is my
build.gradle(Module:app)
file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.sunshine.bbreaker.appet_i"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:+'
compile 'com.github.navasmdc:MaterialDesign:1.+@aar'
compile 'com.android.support:appcompat-v7:22.0.+'
// GuillotineMenu
compile project(":guillotinemenu")
}
settings.gradle(项目设置)文件:
include ':app', ':guillotinemenu'
project(':guillotinemenu').projectDir = new File('libs/guillotinemenu')
的build.gradle(项目:guillotinemenu)文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}} allprojects {
repositories {
jcenter()
}}
settings.gradle(项目:guillotinemenu)文件:
include ':app', ':library'
的build.gradle(guillotinemenu)文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.yalantis.guillotine.sample"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':library')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.jakewharton:butterknife:6.1.0'
}
让我知道如果你需要任何更多的信息。先谢谢了。
Let me know if you need any more information. Thanks in advance.
推荐答案
您应该有一个结构是这样的:
You should have a structure like this:
projectRoot
app
build.gradle
library
build.gradle
build.gradle
settings.gradle
每个模块都有自己的的build.gradle
文件。另外,根/ settings.gradle
定义一个项目中的所有模块。请勿使用其他settings.gradle你的模块里面。
Each module has own build.gradle
file. Also the root/settings.gradle
defines all modules inside a project. Don't use another settings.gradle inside your module.
在 settings.gradle
include ':app', ':library'
在的build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
在库/的build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion ...
buildToolsVersion ...
defaultConfig {
....
}
}
dependencies {
//....
}
在应用/的build.gradle 使用您的文件,但改变:
In app/build.gradle use your file but change:
dependencies {
//...
// GuillotineMenu
compile project(":library")
}
更新:
下面您的评论之后,我认为你的情况库文件夹是另一个项目的根文件夹。
这意味着你应该是指在模块这个项目中。
After your comment below, I think that in your case the library folder is the root folder of another project. It means that you should refer to the module inside this project.
projectRoot
app
build.gradle
libs
guillotinemenu
build.gradle //top level file of guillotinemenu project
-->> module
build.gradle //build.gradle of the module
因此,改变你的projectRoot的settings.gradle。
So change the settings.gradle of your projectRoot.
include ':app', ':guillotinemenu'
project(':guillotinemenu').projectDir = new File('libs/guillotinemenu/module')
模块(库/ guillotinemenu /模块)应该有一个的build.gradle
为库/的build.gradle 如上所述。
这篇关于摇篮同步错误:一个名为“默认”配置未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!