英文:
Android Studio: Gradle error; A problem occurred evaluating project ':connectivity_plus'
问题
I have encountered the error while working on an android project for college of mine.
FAILURE: Build failed with an exception.
-
Where:
Build file 'C:\Users\william\AppData\Local\Pub\Cache\hosted\pub.dev\connectivity_plus-4.0.1\android\build.gradle' line: 24 -
What went wrong:
A problem occurred evaluating project ':connectivity_plus'.
No signature of method: build_bou4ub0wbhz1n3u4prip3694v.android() is applicable for argument types: (build_bou4ub0wbhz1n3u4prip3694v$_run_closure2) values: [build_bou4ub0wbhz1n3u4prip3694v$_run_closure2@3428450e]
Upon checking the build.gradle file, I don't know what the error is and what should be done. But within it, here's what it has:
group 'io.flutter.plugins.connectivity'
version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
}
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 33
namespace 'dev.fluttercommunity.plus.connectivity'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 19
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
}
As per looking up this error, I haven't seen anyone else encounter that specific error regarding 'connectivity_plus' so I am not sure what to do about it. I'm not really an expert on Gradle either since the only programming I have done so far are basic Java, Python, and Flutter.
Any suggestions would be helpful to fix this.
By the way, this was done on Gradle 7.4.2, Flutter 3.10.1, and having Java 17.
英文:
As title says, I have encountered the error while working on an android project for college of mine.
The entire error says this following:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\william\AppData\Local\Pub\Cache\hosted\pub.dev\connectivity_plus-4.0.1\android\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':connectivity_plus'.
> No signature of method: build_bou4ub0wbhz1n3u4prip3694v.android() is applicable for argument types: (build_bou4ub0wbhz1n3u4prip3694v$_run_closure2) values: [build_bou4ub0wbhz1n3u4prip3694v$_run_closure2@3428450e]
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Upon checking the build.gradle file, I don't know what the error is and what should be done. But within it, here's what it have:
group 'io.flutter.plugins.connectivity'
version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
}
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 33
namespace 'dev.fluttercommunity.plus.connectivity'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 19
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
}
As per looking up this error, I haven't seen anyone else encounter that specific error regarding 'connectivity_plus' so I am not sure what to do about it. I'm not really an expert on gradle either since the only programming I have done so far are basic Java, Python and Flutter.
Any suggestions would be helpful to fix this.
By the way, this was done on Gradle 7.4.2, Flutter 3.10.1 and having Java 17
答案1
得分: 0
问题似乎出现在 android
块中。
错误明确提到没有适用于给定参数的 android()
方法的签名。这通常发生在 Gradle 版本和正在使用的 Android Gradle 插件版本之间不匹配时。
要解决此问题,您可以尝试以下步骤:
-
更新 Gradle 版本。在您项目的
build.gradle
文件中(不是在 'connectivity_plus' 库中的那个),确保您正在使用兼容的 Gradle 版本。 -
同步项目。在对 Gradle 文件进行任何更改后,重要的是将项目与更新的配置进行同步。在Android Studio中,您可以单击“与Gradle文件同步项目”按钮,或者从菜单中选择“文件” -> “与Gradle文件同步项目”。
英文:
It seems that the issue lies in the android
block.
The error specifically mentions that there is no signature of the method android()
that is applicable for the given argument. This typically occurs when there is a mismatch between the Gradle version and the Android Gradle plugin version being used.
To resolve this issue, you can try the following steps:
-
Update the Gradle version. In the
build.gradle
file of your project (not the one in the 'connectivity_plus' library), make sure you are using a compatible Gradle version. -
Sync your project. After making any changes to the Gradle files, it's important to sync your project with the updated configurations. In Android Studio, you can click on the "Sync Project with Gradle Files" button or select "File" -> "Sync Project with Gradle Files" from the menu.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论