Pregunta

I found the same question Duplicate. But I have no maven dependency. I have subproject dependency.

I want to use one project dependency only for one flavor. This is my 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"
        }
     }
}

This is console out on build command

./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
¿Fue útil?

Solución

Solution are founded. Flavors should be declared before using it, so right build gradle is:

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

       compileSdkVersion "Google Inc.:Google APIs:19"
       buildToolsVersion "18.1.1"
   }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top