问题
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'
}
回答1:
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
}
回答2:
I had the same error message until I commented out everything in the android plugin except the compile sdk version, trying to get back to a successful build config.
android {
compileSdkVersion 23
/*
...
*/
}
Then, I started uncommenting things until I narrowed the problem down to using the following incorrectly.
ProductFlavors {
...
}
I'm not sure if you're using the same block, but at the moment, I'm leaving it commented out because I'm not sure it's needed. Once I got rid of it though, I was receiving other errors about sdk root dir location, so I was able to fix those.
I hope this helps!
回答3:
in my case I needed to comment out this lines in gradle
androidExtensions{
experimental = true
}
回答4:
Best thing you can do is comment parts of your build.gradle
file related to the issue until you get a good build and them uncomment 1 by 1 until you find the problem. I had the same error and it was related with a typo in one of the app build.gradle
blocks. I was using:
android {
...
buildFeature {
...
}
}
instead of
android {
...
buildFeatures {
...
}
}
Good luck!
回答5:
I was getting a similar error because the versionCode
was being taken from a properties file, but the versionCode needs to be an integer and not a string, so toInteger()
was needed.
Nice logs, android.
回答6:
I added debug under buildTypes in the gradle file and missed a comma after "API_URL":
not working:
buildTypes {
...
debug {
buildConfigField "String", "API_URL" "\"http://myapi.com/\""
}
}
working:
buildTypes {
...
debug {
buildConfigField "String", "API_URL", "\"http://myapi.com/\""
}
}
good luck!
回答7:
It is because there's syntax error in android{..}
part of build.gradle
You've used implementationSdkVersion
which should ideally be compileSdkVersion
. Error in variable names in android{..}
leads to such errors.
TLDR;
Replace implementationSdkVersion
with compileSdkVersion
回答8:
I'm new to Android but i got a message similar to yours today when i try to use a different version (not the suggested ones) of the Gradle plugin and gradle engine on Android Studio 4.1 canary.
When I had on my App build.gradle these lines:
task wrapper(type: Wrapper){
gradleVersion = '5.6.4'
}
and on my build.gradle for the module this line
classpath 'com.android.tools.build:gradle:3.6.3'
This was the message i got with previous settings:
A problem occurred evaluating project ':app'.
> No signature of method: build_5dcjpn4h9nkpym0yszxs5w2uh.android() is applicable for argument types: (build_5dcjpn4h9nkpym0yszxs5w2uh$_run_closure1) values: [build_5dcjpn4h9nkpym0yszxs5w2uh$_run_closure1@2e4515b3]
The way i found to solve this error was changing version for the gradle plugin on my build.gradle for the module like this
classpath 'com.android.tools.build:gradle:4.0.0'
I hope this could help you. Happy coding!
回答9:
Make sure you are using the kotlin android plugin instead of the kotlin jvm plugin.
apply plugin: 'kotlin-android' // NOT kotlin-jvm
回答10:
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
回答11:
Try to comment this in your app level build.gradle
file
openOptions {
disable 'InvalidPackage'
}
回答12:
I had a similar issue because I had added a trailing comma ,
in defaultConfig in android/app/build.gradle
回答13:
In my case, the error cause is below
compilpepeeSdkVersion
rather than
compileSdkVersion
回答14:
Thanks for mentioning to just comment things and test, for me it was:
kapt {
useBuildCache = true
}
Removed it, everything was building again. Happened after updating Kotlin version.
回答15:
Old issue but worth noting you might need to follow the migration guide here if you see this issue:
https://developer.android.com/topic/libraries/view-binding/migration
For me, removing the line apply plugin: 'kotlin-android-extensions'
and adding view binding as below resolved the issue:
buildFeatures {
viewBinding true
}
来源:https://stackoverflow.com/questions/61807520/how-to-fix-error-no-signature-of-method-build-ap86oam3dut3pxce3x49rdtma-androi