Usman Liaqat
Usman Liaqat

Reputation: 1891

How to fix ERROR: No signature of method: build_ap86oam3dut3pxce3x49rdtma.android()?

ERROR: No signature of method: build_ap86oam3dut3pxce3x49rdtma.android() is applicable for argument types: (build_ap86oam3dut3pxce3x49rdtma$_run_closure1) values: [build_ap86oam3dut3pxce3x49rdtma$_run_closure1@47588b04]

The build gradle is:

apply plugin: 'com.android.application'

    android{
    implementationSdkVersion 28
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.uiresource.taksiku"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        androidTestImplementation('com.android.support.test.espresso:espresso-core:2.3-alpha', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        implementation "com.android.support:appcompat-v7:$var"
        implementation 'com.android.support:design:28.0.0'
        testimplementation 'junit:junit:4.13'
        implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta5'
        implementation 'de.hdodenhof:circleimageview:3.1.0'
        }

Upvotes: 189

Views: 226696

Answers (30)

Rahul Kumar Tiwari
Rahul Kumar Tiwari

Reputation: 129

The problem is related to the Android section in build.gradle. Comment your code and replace with this code. It will be work.

android {
    compileSdkVersion 33

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        applicationId "com.itfosters.meditation"
        minSdkVersion 21
        targetSdkVersion 32
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }

    }
}

Upvotes: 0

handlerFive
handlerFive

Reputation: 879

This same exception is observed when adding a new build variant to the existing product flavors.

If the new product flavor is not added at the very bottom of the list then this expectation is thrown as below :

No signature of method: build_aptxpbpw526o3g8dsf3d2sj5h.android() is applicable for argument types: (build_aptxpbpw526o3g8dsf3d2sj5h$_run_closure1) values: [build_aptxpbpw526o3g8dsf3d2sj5h$_run_closure1@5670e65f]

Adding a new product flavor at any random position(not at the end) in the list is causing this. Adding the new product flavor at the list end solved my issue.

Upvotes: 0

Rumit Patel
Rumit Patel

Reputation: 12479

In my case I mistakenly wrote the below lines TWICE.

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

Upvotes: 0

Florian K
Florian K

Reputation: 2148

In my case (old flutter project), the solution was to remove the "^" in pubspec.yaml for the lib causing troubles. The caret sign looks for any version from the specified version up to (but not including) the next non-breaking version is ok.

replace

pub: ^x.x.x

by

pub: x.x.x

It was making conflicts with a more recent version of the package

Upvotes: -1

James Idowu
James Idowu

Reputation: 261

I my case, I had to remove this from the app/build.gradle

useProguard true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

Upvotes: -1

Abdullah Opadeji
Abdullah Opadeji

Reputation: 236

Very simple! This is specific to a project, not entirety of all projects.

This worked for me: Erase the entire thing in your android/app/build.gradle But backup before you do! Please!!

Replace everything with any of your project that-is-working's android/app/build.gradle, and replace the applicationId with the original.

I hope this works your you too!

Upvotes: 0

vitralyoz
vitralyoz

Reputation: 618

useProguard true command this line under app/build.gradle

//useProguard true

Upvotes: 0

miguel
miguel

Reputation: 16580

Remove namespace from the android block and put the package name back into AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="you.package.here">

</manifest>

Upvotes: 3

ANDYNVT
ANDYNVT

Reputation: 661

If you are trying to reduce aab file size and add some config to build.gradle file.

Remove these 2 lines will help

   buildTypes {
        release {
            shrinkResources true // <- this
            useProguard true // <- this
            .....

Upvotes: 0

Sajidkhan
Sajidkhan

Reputation: 618

As answered by @miguel, I solved the said issue by removing the namespace line from android block under Gradle. I am going to share a screenshot which may elaborate the solution clearly. enter image description here`

// namespace 'com.flashy.texting'`

Upvotes: 0

Dhvani023
Dhvani023

Reputation: 1207

I had same problem, so I tried to comment element inside android{} one by one

After commenting

    //    appVersion '3.1.3'
    //    outputFileName 'wmc' 
    //    enableCrashlytics()
    //    ignoreNonProductionReleaseVariants()

it worked fine.

Upvotes: 2

AmigoPal
AmigoPal

Reputation: 39

I had this issue, and tried out all the possibilities of the answers given. Most of the answers suggested to disable proguard. But I wanted to use Proguard. So by enabling Proguard i was able to fix this issue.

Following thing worked for me. I have been pointing

classpath 'com.android.tools.build:gradle:7.2.1'

in android/build.gradle. Now to overcome this issue i pointed to

classpath 'com.android.tools.build:gradle:4.1.3'

Hope this helps for you as well !

Upvotes: 0

niaz muhammad
niaz muhammad

Reputation: 75

you only need to remove the below line from your build.gradle file in the app level

useProguard = true

Upvotes: 2

ploth
ploth

Reputation: 455

There is no general answer to this problem. There is just something wrong with the app/build.gradle.

In my case I defined a variable named versionCode which caused the error. Renaming it to e.g. versionCode_ fixed the problem.

Upvotes: 2

Rem
Rem

Reputation: 382

I'm using JAVA, but for some reason Android Studio added kotlinOptions into android block without my knowledge. And then the same error happened. I put here just in case someone need it.

android {
    // ...

    // remove this block if you are using Java
    kotlinOptions {
        jvmTarget = '1.8'
    }

    // ...
}

Upvotes: 8

Muzammil Hussain
Muzammil Hussain

Reputation: 1272

i was trying to add parcelable plugin in my project. this was the same error in my case too. Because, JetBrains extracted the Parcelize from Kotlin Android Extensions to a new plugin, kotlin-parcelize

So, If you want to add easy parcelable in kotlin then follow these steps:

First you will need to add kotlin-parcelize plugin to your module

plugins {
    ..
    id 'kotlin-parcelize'
}

Then change your old import statement from

import kotlinx.android.parcel.Parcelize

to

import kotlinx.parcelize.Parcelize

Example:

import kotlinx.parcelize.Parcelize

import android.os.Parcelable

@Parcelize
class User(

val name: String, 
val age: Int

): Parcelable

Upvotes: 4

Chintan Parmar
Chintan Parmar

Reputation: 2535

If you are using kotlin version 1.4.21 or newer, kotlin-android-extension is deprecated. So if you removing the plugin you also have to remove the android experimental extension block. In my case, I had to remove these pieces of code.

apply plugin: 'kotlin-android-extensions'


androidExtensions {
    experimental = true
}

But if above did not fix it

This a kind of general and/or wrapping error which hides the real cause and/or problem, hence to see actual error message, try something like:

./gradlew :app:assembleDebug --stacktrace

And search for resulting real error-message instead.

Upvotes: 145

giorgio79
giorgio79

Reputation: 4199

I had this exact same issue. It is a nasty one.

I followed the answer first here Deprecated Gradle features not compatible and ran in the terminal

cd android && ./gradlew clean && ./gradlew :app:bundleRelease

the gradlew command gave more detialed feedback, and turned out my Java and JDK were 32bit instead of 64 and also outdated...

This resulted in further errors, but could resolve them step by step: Invalid initial heap size -Xms4096M Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_151 contains a valid JDK installation

Upvotes: 0

oiyio
oiyio

Reputation: 5925

In my case, the error cause is below

compilpepeeSdkVersion

rather than

compileSdkVersion

Upvotes: -2

Sumit Saurabh
Sumit Saurabh

Reputation: 1436

I just removed useProguard true in build.gradle > android > buildTypes, and it worked for me.

Upvotes: 10

Harisewak
Harisewak

Reputation: 580

I received this error while creating a new Jetpack Compose project. 'app' module's build.gradle was cracking up.

Removing packagingOptions did the trick for me ->

packagingOptions {
        
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
        
    }
}

Upvotes: 2

suther
suther

Reputation: 13588

In my case I need to remove following in app/build.gradle:

packagingOptions {
        jniLibs {
            pickFirsts += ['lib/armeabi-v7a/libc++_shared.so', 'lib/arm64-v8a/libc++_shared.so', 'lib/x86/libc++_shared.so', 'lib/x86_64/libc++_shared.so']
        }
    }

Upvotes: 0

TWiStErRob
TWiStErRob

Reputation: 46480

I had the same problem with a vanilla just-created new project in Android Studio Bumblebee (2021.1):

The auto-generated build.gradle had this in it:

buildTypes {
    release {
        minifyEnabled false
        proguardFiles
            getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

Notice that proguardFiles "function call"'s parameters are on a separate line, this is not valid Groovy code.

Upvotes: 0

gtxtreme
gtxtreme

Reputation: 3576

I had mispelled signingConfig as signingConfigs

So it is actually signingConfig signingConfigs.{yourVariantName}

And NOT signingConfigs signingConfigs.{yourVariantName}

Upvotes: 1

Bilal Yaqoob
Bilal Yaqoob

Reputation: 998

Today I got this error when I was making signed apk and I made a mistake while doing setup for playstore, In android/app/build.gradle

signingConfigs{
debug{
 .....
 .....
}
release {....}  // I added the release config outside the signing config
}

Correct-way-todo-just-for-ref

Upvotes: 0

Visal Varghese
Visal Varghese

Reputation: 455

Remove this line, it will work.

includeCompileClasspath true

Upvotes: 0

Muhammad Umer Yasin
Muhammad Umer Yasin

Reputation: 149

This problem is common in Flutter 2.8

  1. Delete Folder with all sub Folder of C:\Users\LENOVO\.gradle

  2. Go File menu > Setting (Ctrl+Alt+S) Go Appearance & Behaviour > System Setting > Android SDK > SDK Tool Tab and then uncheck Android SDK Build-Tool press OK Button 3)Run Project (Shift+F10) in Andriod Studio it will Download all required files from the internet and your issue resolve

    enter image description here

After if the issue is Not resolved then Second Step is:

  1. Go > android\app\build.gradle in your project Please Add > minSdkVersion 19 or 20 // Remove it because, 16 is by default minSdkVersion in flutter 2.8 //minSdkVersion flutter.minSdkVersion
  2. add multiDexEnabled true if file size increase from limits

enter image description here

Upvotes: 3

bra.Scene
bra.Scene

Reputation: 628

There's no unique solution for this error, except that it's a syntax error inside build.gradle file.

Upvotes: 11

Mona Baharlou
Mona Baharlou

Reputation: 1521

In Android Studio 2021.1.1 Canary 12, I removed

plugins{
   ...
   id 'kotlin-android-extensions'
}

But forgot to remove this from

android{
    androidExtensions {
            experimental = true
        }
}

after removing androidExtension block my problem solved

Upvotes: 13

Shogun Nassar
Shogun Nassar

Reputation: 633

I removed this code from my Gradle:

javaCompileOptions {
        annotationProcessorOptions {
            includeCompileClasspath true
        }
    }

Upvotes: 15

Related Questions