Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'OutputFormat' for extension 'dexcount' of type com.getkeepsafe.dexcount.DexCountExtension.
gounthar opened this issue ยท 8 comments
Hello there,
I tried a default configuration with DexCount Gradle plugin:
buildscript {
repositories {
[...]
}
dependencies {
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:3.0.1'
[...]
apply plugin: 'com.getkeepsafe.dexcount'
dexcount {
// When false, no build outputs will be counted. Defaults to true.
enabled = true
// The format of the method count output, either "list", "tree", "json",
// or "yaml".
format = OutputFormat.LIST
// When true, individual classes will be included in the package list -
// otherwise, only packages are included.
includeClasses = false
// When true, the number of classes in a package will be included in the
// printed output.
includeClassCount = false
// When true, the number of fields in a package or class will be included
// in the printed output.
includeFieldCount = true
// When true, the total number of methods in the application will be included
// in the printed output.
includeTotalMethodCount = false
// When true, packages will be sorted in descending order by the number of
//methods they contain.
orderByMethodCount = false
// When true, the output file will also be printed to the build's standard
// output.
verbose = false
// Sets the max number of package segments in the output - i.e. when set to 2,
// counts stop at `com.google`, when set to 3 you get `com.google.android`,
// etc. "Unlimited" by default.
maxTreeDepth = Integer.MAX_VALUE
// When true, Team City integration strings will be printed.
teamCityIntegration = false
// A string which, if specified, will be added to TeamCity stat names.
// Null by default.
teamCitySlug = null
// When set, the build will fail when the APK/AAR has more methods than the
// max. 0 by default.
maxMethodCount = 64000
// When true, prints the declared method and field count. Only allowed in
// library modules. False by default.
printDeclarations = true
}
Android Studio Artic Fox 2020.3.1 Patch 3 gives me an error: `Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'OutputFormat' for extension 'dexcount' of type com.getkeepsafe.dexcount.DexCountExtension.
I'm using Java 11, Gradle 7.3 and Android Gradle Plugin 7.0.3.
Could you please let me know what I did wrong?
Thanks a lot.
`
Interesting. Maybe you have to import com.getkeepsafe.dexcount.OutputFormat
now? It's worth trying.
That error message, by the way, is Groovy trying to be magical. The OutputFormat
type evidently isn't in scope so it thinks you're trying to call a method OutputFormat()
which doesn't exist.
Incidentally, if you're just leaving the default configuration values as they are, you don't have to include them. You can just leave out the entire dexcount { ... }
block, and things will work fine.
Thanks for your answer Benjamin.
Importing the class didn't change a thing...
WIthout import, it works with the command line on my CI build. It's just the combination of Android Studio and Gradle on my machine that is not happy.
As for the dexcount { ... }
block, I already have a custom one, but commented it out and replaced with the default one, just in case.
Okay, interesting. So what if you just fully-qualify the name, e.g.
dexcount {
format = com.getkeepsafe.dexcount.OutputFormat.LIST
...
}
Also, Gradle used to (maybe still does?) auto-convert string arguments to enum values, so maybe you could try format = "LIST"
?
Nope, never mind, didn't work for me.
Alright. I modified our integration test to explicitly import the OutputFormat
type and this seems to work. Here's the entire app/build.gradle
file:
import com.getkeepsafe.dexcount.OutputFormat
plugins {
id "com.android.application"
id "com.getkeepsafe.dexcount"
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.getkeepsafe.dexcount.integration"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
minifyEnabled true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
output.outputFileName = output.outputFileName.replace(".apk", "-it.apk")
}
}
}
dexcount {
verbose = true
printVersion = true
teamCitySlug = project.name
format = OutputFormat.LIST
}
dependencies {
implementation "com.android.support:appcompat-v7:28.0.0"
testImplementation "junit:junit:4.12"
}
Also, Gradle used to (maybe still does?) auto-convert string arguments to enum values, so maybe you could tryformat = "LIST"
?Nope, never mind, didn't work for me.
Not for me either. Caused by: java.lang.IllegalArgumentException: Cannot set the value of extension 'dexcount' property 'format' of type com.getkeepsafe.dexcount.OutputFormat using an instance of type java.lang.String.
Okay, interesting. So what if you just fully-qualify the name, e.g.
dexcount { format = com.getkeepsafe.dexcount.OutputFormat.LIST ... }
I get Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'com' for extension 'dexcount' of type com.getkeepsafe.dexcount.DexCountExtension.
Hmm :(
If the example I posted above doesn't work for you, then I'm not sure how to help you here. I'm not able to reproduce that particular failure.
I totally get it.
Thanks for your help anyway, and keep up the good work.