当尝试将我的 android 项目与 gradle 同步时,出现以下错误:
Unable to load class 'com.android.build.gradle.AppPlugin'.
This is an unexpected error. Please file a bug containing the idea.log file.
还有:
Build file 'C:\Users\user\Desktop\android\android-anpr-master\app\build.gradle' line: 1
A problem occurred evaluating project ':app'.
> Could not find implementation class 'com.android.build.gradle.AppPlugin' for plugin 'com.android.application' specified in jar:file:/C:/Users/aprotiere/.gradle/caches/jars-9/f84232a270d8a27731cbe96e1da64c89/gradle-8.1.2.jar!/META-INF/gradle-plugins/com.android.application.properties.
这是我的 build.gradle (应用程序):
apply plugin: 'com.android.application'
android {
compileSdkVersion 31
buildToolsVersion '19.0.3'
defaultConfig {
applicationId "com.DVLA.testapp"
minSdkVersion 14
//noinspection OldTargetApi,EditedTargetSdkVersion
targetSdkVersion 31
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false // You can enable minification if needed
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url 'http://maven2.javacv.googlecode.com/git/' }
}
dependencies {
implementation ':1.6.1' // Use the latest version
implementation 'com.android.tools.build:gradle:8.1.2'
implementation 'joda-time:joda-time:2.12.5' // Update the version of Joda-Time
implementation files('libs/javacpp.jar')
implementation files('libs/javacv.jar')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':libraries:opencv') // Make sure the project path is correct
}
build.gradle(项目):
// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
allprojects {
repositories {
mavenCentral()
google()
}
}
如果您需要任何缺失的信息,请告诉我。我可以提供日志和其他文件,例如 gradle-wrapper.properties,但我不希望帖子这么长,除非需要。
谢谢
同样的问题,你解决了吗?