Gradle plugin 0.9.0

839 views
Skip to first unread message

Xavier Ducrohet

unread,
Mar 5, 2014, 2:18:27 PM3/5/14
to adt...@googlegroups.com
Release notes: http://tools.android.com/tech-docs/new-build-system

--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Streets Of Boston

unread,
Mar 5, 2014, 3:12:44 PM3/5/14
to adt...@googlegroups.com
Question about library build-variants with app build-variants.

I have a number of apps with a number of build-variants (defined in flavorGroups and productFlavors).
I have a library project supporting all these apps.

The variant-sources in the apps redefine stuff (code/resources) that are originally defined/declared in the library project. 
These re-definitions are the same for each app, duplicated, because the library project didn't support build-variants.

Now that library projects support build-variants, is there a way to tie an app's product-flavor to a library build-variant and move the variant-sources from the app-projects to the variant-sources of the library-project?

Thanks!

Xavier Ducrohet

unread,
Mar 5, 2014, 4:04:38 PM3/5/14
to adt...@googlegroups.com
You could, but the dependencies are very manual for now.

So in your apps you'd have to do something like this:

dependencies {
    flavor1Compile project(path: ':lib1', configuration: 'flavor1Release')
    flavor2Compile project(path: ':lib1', configuration: 'flavor2Release')
}

This is really not great if you have a different flavor groups, but it's possible at least.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ihor Kushnirenko

unread,
Mar 5, 2014, 5:12:46 PM3/5/14
to adt...@googlegroups.com
I have this problem in IDEA 13.0.2^
"Build script error, unsupported Gradle DSL method found: 'release()'!"

Jake Wharton

unread,
Mar 5, 2014, 5:18:25 PM3/5/14
to adt...@googlegroups.com
That shouldn't prevent you from building, though. What about IDEA 13.1 EPA?


On Wed, Mar 5, 2014 at 2:12 PM, Ihor Kushnirenko <ihor.kus...@gmail.com> wrote:
I have this problem in IDEA 13.0.2^
"Build script error, unsupported Gradle DSL method found: 'release()'!"

--

Xavier Ducrohet

unread,
Mar 5, 2014, 5:21:35 PM3/5/14
to adt...@googlegroups.com
Looks like you have a library project where you didn't update your build script to match the new DSL.

If you have 
android {
  debug {
  }
  release {
  }
}

you need to change it to the same format as app project:
android {
  buildTypes {
    debug {
    }
    release {
    }
  }
}




On Wed, Mar 5, 2014 at 2:12 PM, Ihor Kushnirenko <ihor.kus...@gmail.com> wrote:
I have this problem in IDEA 13.0.2^
"Build script error, unsupported Gradle DSL method found: 'release()'!"

--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Croc

unread,
Mar 10, 2014, 8:03:47 AM3/10/14
to adt...@googlegroups.com
I know that bug 52962 hasn't been fixed yet, but I've found out that I can specify/build debug variant of a library and everything seems to work fine, except that BuildConfig file is not included in the APK (if I build release variant everything works fine, BuildConfig is included in the APK). I don't really know where the problem is because sources seem to build correctly as in, I have in my library build/source/buildConfig/debug/packagename/BuildConfig.java. Is there something I'm missing or this just isn't supported yet (as per bug status)? I'm using plugin 0.9.0 (and AS 0.5.1). Oh, and I'm building the debug/release lib variant by specifying defaultPublishConfig "debug" (maybe that's the problem?).

Streets Of Boston

unread,
Mar 10, 2014, 1:00:07 PM3/10/14
to adt...@googlegroups.com
I tried your suggestion, but i can't get it to work.

I keep getting these type of error messages when syncing the gradle file
(envTest and Mediaarc are two flavors, Debug is the build type).

I checked that 'envTestMediaarcDebug' is a proper build flavor.

In build.gradle there is this line in the dependencies:

    envTestMediaarcDebugCompile project(path: ':libraries:android-jenga-rest', configuration: 'mediaarcDebug')

When syncing the build.gradle, it gives this error:

    Build script error, unsupported Gradle DSL method found: 'envTestMediaarcDebugCompile()'!

I tried with and without the 'Debug', i tried 'compileEnvTestMediaarcDebug' instead, (with and without the 'Debug' part)...
It always give the DSL method not found error.

I probably do something wrong, but I can't figure out what....

Xavier Ducrohet

unread,
Mar 10, 2014, 1:28:13 PM3/10/14
to adt...@googlegroups.com
Do a "gradle dependencies" from the command line to see all the project configurations to make sure the one you need is there.


For more options, visit https://groups.google.com/d/optout.

Streets Of Boston

unread,
Mar 10, 2014, 2:15:56 PM3/10/14
to adt...@googlegroups.com
I get a long list of dependencies. This is part of that list:

This 'gradlew dependencies libraries:android-jenga-rest:dependencies' produces this:

...
...
envTestMediaarcDebug - Published Configuration for Variant envTestMediaarcDebug
\--- project :libraries:android-jenga-utils
     +--- com.android.support:support-v4:19.0.+ -> 19.0.1
     \--- com.android.support:support-v13:19.0.+ -> 19.0.1
          \--- com.android.support:support-v4:19.0.1

envTestMediaarcDebugCompile - Classpath for compiling the envTestMediaarcDebug sources.
No dependencies

envTestMediaarcDebugProvided - Classpath for only compiling the envTestMediaarcDebug sources.
No dependencies

envTestMediaarcDebugPublish - Classpath only used for publishing.
No dependencies

envTestMediaarcProvided - Classpath for only compiling the envTestMediaarc sources.
No dependencies

envTestMediaarcPublish - Classpath only used for publishing.
No dependencies
...
...

It looks like the list of depencies lists the envTestMediaarcDebugCompile one. However, using it in the 'dependencies' for compilation if fails with that DSL error. 

Xavier Ducrohet

unread,
Mar 10, 2014, 2:43:43 PM3/10/14
to adt...@googlegroups.com
oh, wheres is your dependencies {} block compared to your android {} block?

The configuration objects are created while parsing the android {} block, so your dependencies one should be after.

Streets Of Boston

unread,
Mar 10, 2014, 7:34:48 PM3/10/14
to adt...@googlegroups.com
No difference. I get the same error.

I tried this build.gradle file.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}
apply plugin: 'android-library'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        minSdkVersion  rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
    }

    flavorGroups "server_environment", "oem"

    productFlavors {
        envTest {
            flavorGroup "server_environment"
        }

        envProd {
            flavorGroup "server_environment"
        }

        mediaarc {
            flavorGroup "oem"
        }

        toshiba {
            flavorGroup "oem"
        }
    }
}

dependencies {
    // compile project(':libraries:android-jenga-utils')

    envTestMediaarcDebugCompile project(':libraries:android-jenga-utils')

    compile files('libs/gson-2.2.4.jar', 'libs/mobileservices-1.0.0.jar', 'libs/jackson-core-asl-1.9.12.jar', 'libs/jackson-mapper-asl-1.9.12.jar', 'libs/simple-xml-2.7.jar')
}


This build.gradle file will give the DSL error.

However, when i replace envTestMediaarcDebugCompile with just envTestCompile or mediaarcCompile, etc, the error goes away the build.gradle file parses/compiles OK.
As soon as I add 'Debug' or 'Release' or use more then one flavor or type combination, i get the error.

Xavier Ducrohet

unread,
Mar 10, 2014, 8:13:15 PM3/10/14
to adt...@googlegroups.com
You said "envTestMediaarcDebug" is a proper build flavor. It's not, it's a build variant (ie a combination of flavor(s) and type).

This is important because we don't support configuration object that represent a variant. We'd like to, but there's an issue that needs to be fixed before we can add then and it's going to take a little while.

What's happening though is that those objects get created anyway, when they shouldn't!

I'm not sure if this is new due to a lot of changes we did for the library flavor support or if it was there before.

What's happening though is that those objects are created too late (in after evaluate) due to the issue mentioned above.

So you could fix it by writing 

afterEvaluate {
   dependencies {
       ....
   }
}

Ultimately this will be fixed, in the meantime I'm kind of leaning toward removing them (if I can because they are created automatically when we create the variant-specific sourcesets we introduced recently).

Xavier Ducrohet

unread,
Mar 10, 2014, 8:16:24 PM3/10/14
to adt...@googlegroups.com
Actually the afterEvaluate trick is not going to work.

This is because while this Configuration object is created, it's not used :\

Streets Of Boston

unread,
Mar 10, 2014, 8:28:35 PM3/10/14
to adt...@googlegroups.com
Then we'll hold off using library variants for now...

Question to satisfy my curiosity :-) :
Not only envTestMediaarcDebug is a variant, but envTestMediaarc is a variant as well? 
Is a (supported) build-flavor a 'variant' that only has exactly one flavor defined (e.g. envTest/mediaarc) without build-type (e.g. debug/release)?

E.g. 
mediaarc --> flavor
envTest --> flavor
envTestMediaarc --> variant
mediaarcDebug --> variant
envTestRelease --> variant

Thanks!

Xavier Ducrohet

unread,
Mar 10, 2014, 8:33:42 PM3/10/14
to adt...@googlegroups.com
envTestMediaarc is a flavor combination. There isn't a good name for it, and usually it's not really used (except for this new sourceset we create for each combnation, and its associated Configuration).

It has the same limitation as the variant specific Configuration: it's created too late.

Dominik Schulz

unread,
Mar 17, 2014, 3:24:50 AM3/17/14
to adt...@googlegroups.com
Hey there,
i have the same problem as Croc, i can compile with defaultpublishconfig debug, but when i deploy and start the app it crashs with an NoClassDefFound Exception, the reason in my case is that it cant find the BuildConfig.class inside the apk.
Does anyone have an Idea?

Xavier Ducrohet

unread,
Mar 17, 2014, 1:43:31 PM3/17/14
to adt...@googlegroups.com
The build config packaging has been fixed for the next release.



--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benjamin Cooley

unread,
Apr 23, 2014, 9:30:16 PM4/23/14
to adt...@googlegroups.com
Xavier, when building the build system is there an easy way to sync to the specific version of the build system that was released? It would be really nice to have a tag or something 'sync to version 0.9.1',

- Ben

Xavier Ducrohet

unread,
Apr 23, 2014, 9:54:50 PM4/23/14
to adt...@googlegroups.com
If you look here: https://android.googlesource.com/platform/tools/base/

You'll see gradle_0.9.0/1/2 tags.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages