Configuration with name 'default' not foun

2019-02-27 04:15发布

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.

Here is settings.gradle from ProjectA

include ':app'
include ':LibraryA'
project(':LibraryA').projectDir = new File('../LibraryA')

Here is dependincies from app build.gradle of 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')
}

I am using Android Studio 1.5.1

If I remove compile project(':LibraryA') from dependencies it builds normally, however then I can't referance classes from LibraryA inside ProjectA.

3条回答
迷人小祖宗
2楼-- · 2019-02-27 04:29

I just do not understand what you want to do. But try changing the following line:

project(':LibraryA').projectDir = new File('../ProjectA')
查看更多
混吃等死
3楼-- · 2019-02-27 04:34

One of your projects does not have a valid gradle file. If your library is not a gradle project convert it to gradle project.

If you add your library as a module and select "gradle" when you are importing i think you'll solve your problem.

查看更多
4楼-- · 2019-02-27 04:45

In your settings.gradle (ProjectA) you are referring the wrong folder.

include ':LibraryA'
project(':LibraryA').projectDir = new File('../LibraryA')

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.

You have to refer to the module inside the LibraryA

project(':LibraryA').projectDir = new File('../LibraryA/app')

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)

查看更多
登录 后发表回答