更新Android Studio到电鳗后,我得到这个错误:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/mohamedhamed/Desktop/connect_app/android/build.gradle' line: 19
* What went wrong:
Plugin [id: 'com.android.application', version: '7.1.2', apply: false] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:7.1.2')
Searched in the following repositories:
Gradle Central Plugin Repository
**几天来,我尝试更新Gradle,如文档中所示,以及这里显示的其他解决方案,但仍然得到相同的错误
我能知道这种情况的正确设置是什么吗**
我的app/build.gradle文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
dependencies {
implementation 'com.android.support:multidex:1.0.3' //enter the latest version
implementation platform('com.google.firebase:firebase-bom:29.0.2')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
}
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdkVersion 33
defaultConfig {
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.elearning.connect"
minSdkVersion 23
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
flutter {
source '../..'
}
apply plugin: 'com.google.gms.google-services'
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '2'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.1'
}
我的android/build.gradle文件:
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
jcenter {
url "https://jcenter.bintray.com/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'com.google.gms:google-services:4.3.15 '
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20-RC2")
}
}
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id("org.jetbrains.kotlin.android") version "1.5.31" apply false
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply(plugin = "org.jetbrains.kotlin.android")
1条答案
按热度按时间6ie5vjzr1#
根据Android Studio和Android Gradle插件的官方文档,对于电鳗,您需要将插件版本更新到7.4版本-请参阅此处Android Gradle插件和Android Studio兼容性
更新android/build.gradle文件中的插件详细信息:
另外,请确保您使用的是最低版本的Gradle 7.5