I am stuck with the following error when I try debugging in VSCode with flutter emulator for Android devices.
What I tried:
- flutter precache
- flutter clean + flutter pub get
- these workarounds – keep giving the same error
At first, it seemed that updating Java and Gradle would fix the problem, but then it started giving this (I haven’t been able to run the code yet):
ERROR:
> Failed to transform mokoSupport.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JetifyTransform: C:DEVELOPMENTFLUTTER_PROJECTSble_provaXXXandroidappapplibsmokoSupport.jar.
> Transform's input file does not exist: C:DEVELOPMENTFLUTTER_PROJECTSble_provaXXXandroidappapplibsmokoSupport.jar. (See https://issuetracker.google.com/issues/158753935)
* 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 8s
┌─ Flutter Fix ─────────────────────────────────────────────────────────────┐
│ This issue appears to be https://github.com/flutter/flutter/issues/58247. │
│ Fix this issue by adding the following to the file │
│ C:DEVELOPMENTFLUTTER_PROJECTSble_provaXXXandroidappbuild.gradle: │
│ android { │
│ lintOptions { │
│ checkReleaseBuilds false │
│ } │
│ } │
└───────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1
My android/build.gradle
buildscript {
ext.kotlin_version = '1.9.20'
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.4.0'
classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
rootProject.buildDir = '../build'
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
My app/build.gradle
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
apply(plugin: "com.android.application")
apply(plugin: "kotlin-android")
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "com.example.ble_prova"
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
lintOptions {
checkReleaseBuilds false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.ble_prova"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation files('mokosupport\libs\mokoBleLib.jar')
implementation files('app\libs\mokoBleLib.jar')
implementation files('app\libs\mokoSupport.jar')
implementation project(path: ':mokosupport')
}
My settings.gradle
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
}
include ":app",':mokosupport'
Java version openJDK 17.0.11 / Gradle version 8.5 / Kotlin version 1.9.20
I really do not understand how to fix this. Please help, I really don’t know what else to do.