【问题标题】:Cannot Evaluate Module : Configuration with name 'default' not found无法评估模块:未找到名称为“默认”的配置
【发布时间】:2016-03-03 15:52:13
【问题描述】:

首先,是的,我知道有多个其他具有相同标题的线程解决了相同的错误,但是经过 3 个完整的工作日后,我无法修复此错误。

项目结构: 基础目录/ -build.gradle

+App/
   + LibProject1/
      -build.gradle
   -build.gradle
   -settings.gradle
   -(code/src/etc..)
+LibProject2/
  -build.gradle
+LibProject3/
  -build.gradle

BaseDir/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
}
}

allprojects {
repositories {
    jcenter()
}
}

Settings.gradle:

include: ":App:LibProject1"
include: ":LibProject2"
include: ":Libproject3"

App/build.gradle:

    buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
}
     }

    allprojects {
        repositories {
            jcenter()
        }
    }

    apply plugin: 'com.android.application'

    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        compile project(":Copy:CordovaLib")
        compile project(':LogManagerAndroidProject')
        compile project(':XBDSInterfaces')
    }

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false

    }
}

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}
}

Library1,2,3/build.gradle:

    buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
}
}

apply plugin: 'com.android.library'

android{
compileSdkVersion 19
buildToolsVersion "19.1.0"

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 19
}

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }
}

}

*请原谅发帖的奇怪格式,我还没有掌握正确发布代码块的窍门。

我遇到的错误发生在我的所有库中。我已经在 app/build.gradle 文件中重新组织了哪些库首先被编译,并且它永远不会通过第一个编译项目行。首先编译哪个 libproject 会引发 Cannot evaluate module : defualt not found 错误。

所有其他线程都告诉我:

1) 确保您的库文件夹有 build.gradle 文件

2) 在你的 build.gradle 文件中有一个 defaultConfig

3) 确保你的 include 语句在你的 settings.gradle 文件中是正确的

还有更多相同的。

我已经确保我所有的 gradle 文件都是正确的,检查了拼写等等。 不知道该怎么做,这个错误是我一段时间以来遇到的最不详细的通知,任何帮助将不胜感激!

【问题讨论】:

  • 你在哪个模块有这个问题?
  • 发生在我的 app/build.gradle 文件中首先编译的库中。我已将该信息添加到问题中,感谢您指出这一点。
  • 但 app/build.gradla 似乎是你的情况下的根级文件
  • 这是一个多项目构建中的单个应用程序,我只是想让这个应用程序单独构建。包含项目中还有 6 个应用程序需要中断并单独构建。
  • 我认为这是问题所在。在项目中,根文件夹中始终有一个 build.gradle。然后任何模块都有自己的 build.gradle

标签: android gradle


【解决方案1】:

我对这个问题的解决方案是我有多个 settings.gradle 文件。确保在您的根目录中只有一个。 这个多项目构建的目录结构没有很好地规划,并且已经设置在我的膝上进行清理。

给未来读者的提示,Android Studio 不会像 eclipse 那样处理多项目构建。这是我的根本错误。

【讨论】:

    猜你喜欢
    • 2016-10-31
    • 1970-01-01
    • 1970-01-01
    • 2013-06-15
    • 1970-01-01
    • 2016-10-17
    • 2014-04-28
    • 2017-05-24
    • 2015-03-31
    相关资源
    最近更新 更多