在 Android Studio 上找不到名称为“默认"的配置错误 [英] Configuration with name 'default' not found error on Android Studio
问题描述
我正在尝试在不复制库项目的情况下测试引用.所以我创建了两个项目,一个是ProjectA,一个是LibraryA.这两个项目都位于 \StudioProjects 文件夹内.我正在尝试从 ProjectA 中引用 LibraryA,但在标题中出现错误.
I am trying to test to reference without copying a library Project. So I created two projects one is ProjectA and one is LibraryA. Both projects are located inside the \StudioProjects folder. I am trying to reference LibraryA from ProjectA and I get the error at the title.
这是 ProjectA
include ':app'
include ':LibraryA'
project(':LibraryA').projectDir = new File('../LibraryA')
这里是 ProjectA
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project(':LibraryA')
}
我使用的是 Android Studio 1.5.1
如果我从它正常构建的依赖项中删除 compile project(':LibraryA')
,但是我不能在 ProjectA 中引用 LibraryA 中的类.
If I remove compile project(':LibraryA')
from dependencies it builds normally, however then I can't referance classes from LibraryA inside ProjectA.
推荐答案
在您的 settings.gradle
(ProjectA) 中,您引用了错误的文件夹.
In your settings.gradle
(ProjectA) you are referring the wrong folder.
include ':LibraryA'
project(':LibraryA').projectDir = new File('../LibraryA')
检查您的图像,LibraryA
文件夹是一个 根 文件夹.
Gradle 正在搜索模块" build.gradle 而在此文件夹中有一个顶级文件配置.
Checking your image, the LibraryA
folder is a root folder.
Gradle is searching for a "module" build.gradle while in this folder there is a top-level file configuration.
必须参考LibraryA里面的模块
project(':LibraryA').projectDir = new File('../LibraryA/app')
当然要注意顶层文件(LibraryA)中是否定义了一些任务或变量.在这种情况下,您必须将它们克隆到顶级文件 (ProjectA) 中
Of course you have to pay attention if some tasks or variable are defined in the top-level file (LibraryA). In this case you have to clone them inside your top-level file (ProjectA)
这篇关于在 Android Studio 上找不到名称为“默认"的配置错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!