Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No signature of method: .android() is applicable for argument types. Exception in build.gradle (app)

  • Exception is: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'

Caused by: groovy.lang.MissingMethodException: No signature of method: build_h12dou32x8mktsbcdinr8fpc.android() is applicable for argument types: (build_h12dou32x8mktsbcdinr8fpc$_run_closure1) values: [build_h12dou32x8mktsbcdinr8fpc$_run_closure1@1630dea1]

like image 597
Gaurav Pandit Avatar asked May 06 '21 12:05

Gaurav Pandit


4 Answers

I had the same issue when migrating to the AGP 7.0 when moving from aaptOptions to androidResources.

For me it was enough to replace

androidResources {
   noCompress '...'
}

with

aaptOptions {
   noCompress '...'
}
like image 134
dnhyde Avatar answered Oct 19 '22 00:10

dnhyde


I had the same issue when migrating to the 'com.android.tools.build:gradle:7.0.0'

I removed the code:

javaCompileOptions {
            annotationProcessorOptions {
                arguments = [fragmentArgsLogWarnings: 'false']
                includeCompileClasspath true
            }
        }

here is desc about how to add it again for kapt https://github.com/sockeqwe/fragmentargs#annotation-processor-options

like image 42
NickUnuchek Avatar answered Sep 19 '22 18:09

NickUnuchek


Best way to deal with this is going in the android { ... } block and start commenting out different methods/blocks until the configuration moves past the .android() error and you'll know which block is causing it. In my case it was a deprecated method in the buildTypes { ... } block.

like image 28
Andrei Verdes Avatar answered Oct 19 '22 01:10

Andrei Verdes


I recently had similar trouble. I had to rerun the project with a "build.gradle" file from another project that didn't have any issues. Then I narrowed the issue down to useProguard true. The issue disappeared after I commented out useProguard true as shown below:

buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled true
        //useProguard true  <-- remove this line
        proguardFiles getDefaultProguardFile('proguard-android.txt')
    }
    debug {
        signingConfig signingConfigs.debug
    }
}
like image 22
Tobechukwu Ezenachukwu Avatar answered Oct 19 '22 00:10

Tobechukwu Ezenachukwu