不同的风味依赖

时间:2014-03-01 19:14:45

标签: android gradle gradlew

我发现了同样的问题Duplicate。但我没有maven依赖。我有子项目依赖。

我想只为一种风格使用一个项目依赖项。这是我的build.gradle

dependencies {
    secureCompile project(':relatedProjects:gd')
}

android {
    compileSdkVersion "Google Inc.:Google APIs:19"
    buildToolsVersion "18.1.1"

     productFlavors {
        google {}
        secure {
            packageName "com.some_secure.package"
        }
     }
}

这是构建命令的控制台

./gradlew clean assembleDebug 

FAILURE: Build failed with an exception.

* Where:
Build file '/home/kulik/project/Notate/notateolearis/notateandroid/build.gradle' line: 27

* What went wrong:
A problem occurred evaluating project ':someproject'.
> Could not find method secureCompile() for arguments [project ':relatedProjects:gd'] on project ':someproject'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 15.957 secs

1 个答案:

答案 0 :(得分:4)

解决方案成立。在使用之前应该声明味道,因此正确的构建gradle是:

   android {
       productFlavors {
           google {}
           secure {
               packageName "com.some_secure.package"
           }
       } 
       dependencies {
           secureCompile project(':relatedProjects:gd')
       }

       compileSdkVersion "Google Inc.:Google APIs:19"
       buildToolsVersion "18.1.1"
   }