android - 在 Android Studio 上引用库项目而不进行复制 - 错误 :Configuration with name 'default' not found

标签 android gradle android-studio android-gradle-plugin build-error

我正在尝试将我的 Android 项目从 Eclipse 迁移到 Android Studio。我有一个在其他项目中使用的库项目,这就是我希望将其分开(不在项目中复制)的原因。为此,我遵循 this answer 。但我收到以下错误:

Error:Configuration with name 'default' not found.

我阅读并尝试了互联网上针对此错误的所有答案,但没有解决我的问题。

设置.gradle

include ':my_android_app'
include ':my_android_project_lib'
project(':my_android_project_lib').projectDir = new File(settingsDir, '../my_android_project_lib')

my_android_app 模块的 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "my.android.app"
        minSdkVersion 15
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(path: ':my_android_project_lib')
}

my_android_app 项目的build.gradle

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

allprojects {
    repositories {
        jcenter()
    }
}

编辑: This answer帮助我解决了问题。我必须将依赖项添加到项目的 build.gradle 文件中。

最佳答案

你能遵循“gradletasks--info”并看看你得到了什么吗?

否则,here你可能有一些有用的东西。

干杯!

关于android - 在 Android Studio 上引用库项目而不进行复制 - 错误 :Configuration with name 'default' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28091831/

相关文章:

android - 如何使用 IntentCompat.makeRestartActivityTask()?

java - 在 Android Studio 中将常量类重构为枚举

android - 有没有办法让 Android studio 格式化代码?

grails - 通过Grails具有可选页面深度/URL变量的URLMappings 3

java - Gradle Build-Android Gradle 3.2 中的数据绑定(bind)错误

android - bbPress 有 API 吗?

android - 如何解决Android中的java.lang.OutOfMemoryError问题

java - Android 用图标构建迷你抽屉导航

java - 如何在本地格式化 Jenkinsfile?

java - 使用@category spring 和 gradle 运行 jUnit 测试