2017-07-19 43 views
0

我正在尝试设置依赖于另一个的gradle模块,并在它们之间传递正确的构建配置。我得到的错误是:如何使用构建类型编译本地gradle模块依赖关系?

Error: Configuration with name 'debug' not found. 

构建类型已正确声明...我需要添加什么?

项目的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:2.1.2' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

应用模块的build.gradle:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.1" 

    defaultConfig { 
     applicationId "xyz.example.gradletest" 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
     debug { } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:24.2.1' 

    debugCompile project(path: ':lib1', configuration: 'debug') 
    releaseCompile project(path: ':lib1', configuration: 'release') 
} 

LIB1模块的build.gradle:

apply plugin: 'com.android.library' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.1" 

    defaultConfig { 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
     debug { } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:24.2.1' 

    debugCompile project(path: ':lib2', configuration: 'debug') 
    releaseCompile project(path: ':lib2', configuration: 'release') 
} 

LIB2模块的build.gradle:

apply plugin: 'com.android.library' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "24.0.1" 

    defaultConfig { 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
     debug { } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:24.2.1' 
} 

回答

0

这些线需要被添加到模块的gradle的 “机器人” 部分的build.gradle文件:

defaultPublishConfig "debug" 
publishNonDefault true 
1

依赖性是共同的释放和调试。 它可能工作,如果您删除

调试{}//删除所有模块的这部分。

来自你的所有模块的gradle文件。