Flutter-intellij: Failed to transform file 'flutter-x86.jar'

Created on 29 Mar 2018  路  17Comments  路  Source: flutter/flutter-intellij

  • What went wrong:
    Could not resolve all files for configuration ':app:debugAndroidTestRuntimeClasspath'.
    > Failed to transform file 'flutter-x86.jar' to match attributes {artifactType=android-classes} using transform JarTransform
    > Transform output file E:\opensdk\openApp\flutter_test2\build\app\intermediates\flutter\flutter-x86.jar does not exist.
question

Most helpful comment

Same problem on gradle 4.9 & android studio 3.2.0-rc03.

The work aground is to add this snippet to app/build.gradle:

afterEvaluate {
    android.applicationVariants.all {
        Task flutterX86Jar = project.tasks.findByName("flutterBuildX86Jar")
        Task checkClasspath = project.tasks.findByName("check${it.name.capitalize()}Classpath")
        if (flutterX86Jar && checkClasspath) {
            checkClasspath.dependsOn flutterX86Jar
        }
    }
}

All 17 comments

What happened to get into this state?

It looks like you might have the wrong version of Gradle. Do any of the work-arounds in https://github.com/flutter/flutter/issues/10630 help?

my gradle version is this :
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
}

@Ezviz-Dingwei
replace
classpath 'com.android.tools.build:gradle:3.0.1'
to
classpath 'com.android.tools.build:gradle:3.1.1'

maybe help u.

I have a project that every time I do flutter clean erases that .jar file and never creates it again. For some reason going to the first commit on my repo makes the build system work flawlessly.

I could find the gradle task that is supposed to run, and it's a hack but it's possible to run it manually:
(cd android/; ./gradlew flutterBuildX86Jar). I would guess that the offending file is flutter_tools/gradle/flutter.gradle from the main repo.

I don't know how to trigger it but I can reproduce it or not at will.

My repo is [email protected]:fmatosqg/flutter_hud.git

Commit 8e3576b breaks it with flutter clean ; flutter run.
Commit e129f12 makes it work.

The offending line in my project is apply plugin: 'kotlin-android'. I added kotlin to the project like I would usually do, and it's confusing the flutter.gradle file somehow. I'll be looking at docs on how to add kotlin to a java project specifically for flutter, since the usual steps for native are breaking something.

This works:


apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

This breaks


apply plugin: 'com.android.application'

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Not sure whether I can make flutter plugin wait for kotlin tasks to be created, THEN try to detect it.

We need a documentation to tell people how to add kotlin to flutter project. Following the steps to add kotlin to existing java project may result in this issue.

/cc @mravn-google, @jakobr-google for gradle advice

Our current Kotlin support amounts to creating a Kotlin-based Flutter project with flutter create -a kotlin myProject. Our Kotlin project template provides some implicit guidance, as it applies the Flutter gradle script after the Kotlin one.

Adding "run-me-last" magic into Gradle scripts is a brittle business, so I think documentation is the way forward---at least until we are able to reduce flutter.gradle's coupling to existing Gradle tasks.

I'm not sure there was ever gradle support for enforcing or mitigating problems on applied plugins. But I'd be happy if we could

  • document how to add kotlin to an existing flutter project
  • add some kind of error/warning if the plugins are in the wrong order. This could be a stretch goal, and I'm not sure how gradle can do this, but it would have saved me lots of time because it was still working when I already had the wrong build.gradle

Since AS doesn't have a way of doing flutter clean I spent weeks with the jar file in the right place, it only began breaking when I used the console.

Same problem. flutter clean will delete flutter-x86.jar and that is it. No more builds after that 馃挴

Delete the build package , then flutter run works for me

@fyzs-n9001 That is exactly what flutter clean does. This introduces the problem we are having and not fix it.

    configure(project(':app')) {
        tasks.forEach { task ->
            println task
            task.dependsOn(flutterBuildX86Jar)
        }
    }

https://github.com/flutter/flutter/issues/10630

any updates or workaround on this .

Same problem on gradle 4.9 & android studio 3.2.0-rc03.

The work aground is to add this snippet to app/build.gradle:

afterEvaluate {
    android.applicationVariants.all {
        Task flutterX86Jar = project.tasks.findByName("flutterBuildX86Jar")
        Task checkClasspath = project.tasks.findByName("check${it.name.capitalize()}Classpath")
        if (flutterX86Jar && checkClasspath) {
            checkClasspath.dependsOn flutterX86Jar
        }
    }
}

The Android support in Flutter projects has changed a lot recently. If this problem comes up again it would be better to report in https://github.com/flutter/flutter/issues

For future reference make sure you have the correct (latest) version of Flutter & Dart configured in Android Studio: Settings: Languages & frameworks > Flutter > Flutter SDK Path / Dart > Dart SDK Path. In my case the error was because I was using an old version of flutter.

Was this page helpful?
0 / 5 - 0 ratings