Skip to content

No signature of method: java.lang.String.uncapitalize() #179

Closed

Description

Hello,

When I use dexcount 0.7.0 with Android Gradle Plugin 2.3.1 and Gradle 3.3 I got the following exception:

Caused by: groovy.lang.MissingMethodException: No signature of method: java.lang.String.uncapitalize() is applicable for argument types: () values: []
Possible solutions: capitalize()
        at com.getkeepsafe.dexcount.DexMethodCountPlugin$Provider.createTask(DexMethodCountPlugin.groovy:177)
        at com.getkeepsafe.dexcount.DexMethodCountPlugin$LegacyProvider$_applyToApkVariant_closure2.doCall(DexMethodCountPlugin.groovy:217)
        at com.getkeepsafe.dexcount.DexMethodCountPlugin$LegacyProvider.applyToApkVariant(DexMethodCountPlugin.groovy:215)
        at com.getkeepsafe.dexcount.DexMethodCountPlugin$LegacyProvider.applyToApplicationVariant(DexMethodCountPlugin.groovy:197)
        at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:382)
        at org.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:170)
        at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:80)
        at com.getkeepsafe.dexcount.DexMethodCountPlugin$Provider$_apply_closure1.doCall(DexMethodCountPlugin.groovy:134)
...

The reasons are:

  1. Method uncapitalize() is used by DexMethodCountPlugin.Provider.
  2. Method CharSequence.uncapitalize() is supported since Groovy 2.4.8.
  3. Version of Groovy bundled with Gradle 3.3 is 2.4.7. Only in Gradle 3.5 this version is upgraded to 2.4.10.

The hot fix solution is to declare uncapitalize method:

String.metaClass.uncapitalize = {
    if (delegate.length() <= 1) return delegate.toLowerCase()
    return delegate[0].toLowerCase() + delegate[1..-1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions