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.
2
Answers
This is a known issue, which I also faced in flutter.
OR
The workaround might be to:
Run the task to generate the missing file first (e.g., https://github.com/flutter/flutter/issues/58247#issuecomment-636500680)
Temporarily disable lint task (e.g., https://github.com/flutter/flutter/issues/58247#issuecomment-636253593)
Reference links :
https://issuetracker.google.com/u/0/issues/157728192
https://issuetracker.google.com/issues/158060799#comment2
https://android.googlesource.com/platform/tools/base/+/1f9787310d64a66370627a2aaefa1e616565c17d
Je te suggère de créer un nouveau projet android avec kotlin dsl,
tu le nomme comme ton dossier android exemple:"com.peter.parker_spd_1",
spécifie bien que tu veut utiliser la collection pour te générer le fichier ‘libs.versions.toml’
a ce moment la tu devrais avoir tout les scripts *.gradle.kts déja formaté avec la nouvelle syntax.
si tout vas bien, ton ide aura acepté la nouvelle version de l’AGP.
je pense que tu as, comme moi, raté un détails pour effectuer la migration.
Les scipts *.gradle, il ne devrais plus ressemblé a çà!
Une fois ton build Réussi
tu creer un nouveau projet flutter, et tu choisis le projet racine qui a ton app flutter qui doit s’appeler comme celui creer précédemment ex: ‘com.peter.parker_spd_2’.
Eh Voila a plus qu’a rajouter flutter dans tes build.gradles
tu devrais pouvoir intégrer tes dépendences via de panneau ‘project structure’.
j’espère repondre a ta question 😉