j2emanue j2emanue - 2 months ago 21
Android Question

gradle cannot find generatedDensities property

I am trying to only generate

mdpi
and
hdpi
drawables for a certain apk I have, but when I try to build the app i get this error:

* Where:
Script '/Users/myuserID/app/build.gradle' line: 40

* What went wrong:
A problem occurred evaluating script.
> No such property: generatedDensities for class: com.android.build.gradle.internal.dsl.ProductFlavor_Decorated

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


the code in the build file looks like this:

defaultConfig {
applicationId “com.myproject.box"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName “6.0"
**generatedDensities = ['mdpi', 'hdpi']**
}


and in the top level
build.gradle
file i have the following defined:

dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}


generatedDensities
is suppose to tell gradle to only create
mdpi
and
hdpi
drawables, why is it not recognized? As soon as i remove the
generatedDensities
the app builds as usual.

You can refer to here for any further clarification on the property.

Answer

You get that error because generatedDensities was added in Android Plugin for Gradle v1.4.0 as stated by the ProductFlavor documentation. As you can see generatedDensities is not available in the v1.3 documentation.

Change your build.gradle to this:

dependencies {
    classpath 'com.android.tools.build:gradle:1.4.0-beta6'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}