I developed an application on my old Windows computer. A year later, I’m trying to run it on a Mac and I can’t solve the problem.
Here are the errors I’ve encountered:
Launching lib/main.dart on Mi 9T Pro in debug mode…
Running Gradle task ‘assembleDebug’…
You are applying Flutter’s app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply
You are applying Flutter’s main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-
Where:
Build file ‘/Users/skv/Apps/Apps/australia/android/build.gradle’ line: 51 -
What went wrong:
A problem occurred evaluating root project ‘android’.
Could not get unknown property ‘flutterVersionCode’ for DefaultConfig$AgpDecorated_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=16, mCodename=’null’}, targetSdkVersion=DefaultApiVersion{mApiLevel=34, mCodename=’null’}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=com.semenov.australia, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=[], buildConfigFields={}, resValues={}, proguardFiles=[], consumerProguardFiles=[], manifestPlaceholders={}, wearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig$AgpDecorated.
- 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.
==============================================================================
2: Task failed with an exception.
-
Where:
Build file ‘/Users/skv/Apps/Apps/australia/android/build.gradle’ line: 51 -
What went wrong:
A problem occurred evaluating root project ‘android’.
Could not get unknown property ‘flutterVersionCode’ for DefaultConfig$AgpDecorated_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=16, mCodename=’null’}, targetSdkVersion=DefaultApiVersion{mApiLevel=34, mCodename=’null’}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=com.semenov.australia, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=[], buildConfigFields={}, resValues={}, proguardFiles=[], consumerProguardFiles=[], manifestPlaceholders={}, wearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig$AgpDecorated.
- 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.
==============================================================================
BUILD FAILED in 748ms
Error: Gradle task assembleDebug failed with exit code 1
Here’s my build.gradle file code:
buildscript {
ext.kotlin_version = '1.9.23'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Указываем версию плагина google-services
classpath 'com.google.gms:google-services:4.4.2'
}
}
// Применяем плагины с помощью блока plugins
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services' version '4.4.2' // Указываем версию плагина здесь
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
//tasks.register("clean", Delete) {
// delete rootProject.buildDir
//}
android {
compileSdkVersion 34 // Ваша версия SDK, если отличается, укажите здесь
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.semenov.australia"
minSdkVersion 16 // Минимальная поддерживаемая версия Android
targetSdkVersion 34 // Ваша версия SDK, если отличается, укажите здесь
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// Конфигурация для релизной сборки
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
// Подключение Kotlin
kotlin {
experimental {
coroutines 'enable'
}
}
// Настройка сборки и плагинов
buildFeatures {
// Использование ViewBinding
viewBinding true
}
// Подключение дополнительных зависимостей и настроек
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
}
flutter {
source '../..'
}
//buildscript {
// ext.kotlin_version = '1.9.23'
// repositories {
// google()
// mavenCentral()
// }
//
// dependencies {
// classpath 'com.android.tools.build:gradle:8.5.0'
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// }
//}
//
//allprojects {
// repositories {
// google()
// mavenCentral()
// }
//}
//
//rootProject.buildDir = '../build'
//subprojects {
// project.buildDir = "${rootProject.buildDir}/${project.name}"
//}
//subprojects {
// project.evaluationDependsOn(':app')
//}
//
//tasks.register("clean", Delete) {
// delete rootProject.buildDir
//}
I tried to set the correct versions everywhere and update everything.
SKV is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.