16
FAILURE: Build failed with an exception.
  • What went wrong: Execution failed for task ':app:lintVitalRelease'.

    Could not resolve all artifacts for configuration ':app:debugRuntimeClasspath'. Failed to transform libs.jar to match attributes {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. Execution failed for JetifyTransform: E:\AndroidStudioProjects\FlutterProject\EduyaariGuruFlutter\eduyaari_guru_flutter\build\app\intermediates\flutter\debug\libs.jar. Failed to transform 'E:\AndroidStudioProjects\FlutterProject\EduyaariGuruFlutter\eduyaari_guru_flutter\build\app\intermediates\flutter\debug\libs.jar' using Jetifier. Reason: FileNotFoundException, message: E:\AndroidStudioProjects\FlutterProject\EduyaariGuruFlutter\eduyaari_guru_flutter\build\app\intermediates\flutter\debug\libs.jar (The system cannot find the path specified). (Run with --stacktrace for more details.) Please file a bug at http://issuetracker.google.com/issues/new?component=460323.

  • 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 1m 8s

Karishma Patel
  • 339
  • 1
  • 2
  • 16
  • Did you find any solution? I am facing the same issue. – Shahzad Akram Jun 18 '20 at 11:52
  • I have the same problem. Can't build APKs, but can build AABs. It also seems that it's looking for the `libs.jar` file in the `debug` folder instead of `release`. – dasfima Jun 25 '20 at 19:45

10 Answers10

39

Step 1. flutter build apk --debug

Step 2. flutter build apk --profile

Step 3. flutter build apk --release

Subair K
  • 1,202
  • 6
  • 21
  • 1
    and if I'm doing CI build? Doesn't make sense to run all three each time – Petro Korienev Jul 27 '20 at 19:51
  • 3
    With Android plugin 4.0 there may be specific problem either end with `debug/libs.jar` or `profile/libs.jar`. This indicates which `apk` you need to build first. In this case it is `debug/libs.jar` so building `--debug` first and then `--release` worked. In my case, it was `profile/libs.jar` so building `--profile` and then `--release` will work. If you want not to follow all three steps, build signed `apk` or `appbudle` with Android Studio, opeing `android directory` in. – Subair K Jul 28 '20 at 11:55
18

The only solution that worked for me was downgrading the gradle.build from

dependencies {
    classpath 'com.android.tools.build:gradle:4.0.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

to

 dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

and changed the gradle-warpper.properties from

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

to

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

Here you can see why you should not just add lintOptions { checkReleaseBuilds false } on the gradle.

Elias Meireles
  • 426
  • 2
  • 7
8

I found the workaround I needed for my case, I believe it will work for you as well.

I've set the checkReleaseBuilds flag to false in the android's app-level build.gradle like so:

android {
    ...
    lintOptions {
        checkReleaseBuilds false
    }
}

Found it here

dasfima
  • 3,203
  • 2
  • 16
  • 19
3

The problem is related to the version. Try changing the version of the plugin. This worked for me.

https://developer.android.com/studio/releases/gradle-plugin?authuser=1&hl=pt-br#updating-gradle

Example:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

classpath 'com.android.tools.build:gradle:3.6.4'
Elletlar
  • 2,819
  • 7
  • 27
  • 33
2

Running these two commands worked for me:

flutter build apk --profile
flutter build apk --release
ivanacorovic
  • 2,125
  • 3
  • 23
  • 35
1

I was having the same issue and tried building --debug and then --release and it still didn't work. However, if you look at the path in your specific error, it should either end with debug/libs.jar or profile/libs.jar. This indicates which apk you need to build first. In OP's case it is debug/libs.jar so building --debug first and then --release worked. In my case, it was profile/libs.jar so building --profile and then --release worked. I'm pretty sure building the --release shouldn't have to access the debug or profile directories though.

If your error says debug/libs.jar, build --debug then --release.
If your error says profile/libs.jar, build --profile then --release.

Reference Link: https://github.com/flutter/flutter/issues/58247#issuecomment-636500680

0

try running flutter clean on the project folder and then trying again. it seems a file got missing from the build folder

Srilal Sachintha
  • 655
  • 1
  • 5
  • 13
0

I have found a solution mentioned here

I got this problem in Android Studio 4.0 when I did a Gradle sync. I fixed it by doing the following:

  1. Open top-level build.gradle and change the gradle classpath to:

    classpath 'com.android.tools.build:gradle:4.0.0'
    
  2. Open gradle\wrapper\gradle-wrapper.properties and change the distribution URL to:

    distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
    
  3. Copy in .idea\jarRepositories.xml from a new project

Here's my new flutter project jarRepositories.xml, you can get your own.

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="RemoteRepositoriesConfiguration">
    <remote-repository>
      <option name="id" value="central" />
      <option name="name" value="Maven Central repository" />
      <option name="url" value="https://repo1.maven.org/maven2" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="jboss.community" />
      <option name="name" value="JBoss Community repository" />
      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="BintrayJCenter15" />
      <option name="name" value="BintrayJCenter15" />
      <option name="url" value="https://jcenter.bintray.com/" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="Google17" />
      <option name="name" value="Google17" />
      <option name="url" value="https://dl.google.com/dl/android/maven2/" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="maven2" />
      <option name="name" value="maven2" />
      <option name="url" value="https://storage.googleapis.com/download.flutter.io" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="maven5" />
      <option name="name" value="maven5" />
      <option name="url" value="https://google.bintray.com/exoplayer/" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="maven4" />
      <option name="name" value="maven4" />
      <option name="url" value="https://maven.fabric.io/public" />
    </remote-repository>
    <remote-repository>
      <option name="id" value="MavenLocal" />
      <option name="name" value="MavenLocal" />
      <option name="url" value="file:$USER_HOME$/.m2/repository" />
    </remote-repository>
  </component>
</project>

No idea how or why, but it worked for me

Shahzad Akram
  • 2,106
  • 17
  • 40
0

In android build.gradle,

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

didn't work for me and throwed cloud firestore error while executing flutter run. So I changed my gradle version to 4.0.1. where flutter run executed successfully, but flutter build apk fails, so I changed its version to 3.5.4.

In android/gradle/wrapper/gradle-wrapper.properties set,

distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

which works perfectly for both flutter run and flutter build apk. In future this gradle version may not support few plugins that we use in our project, in that case upgrade to the next gradle version. refer gradle versions here: How Do I Fix "unexpected element <queries> found in <manifest>"?

Gowtham MG
  • 11
  • 1
  • 1
-3

The Android Gradle LintPerVariantTask now appears to be adding JARs from all build variants to its inputs: https://android.googlesource.com/platform/tools/base/+/1f9787310d64a66370627a2aaefa1e616565c17d

The libapp.so libraries containing the app's compiled Dart code are packaged in a JAR, and a different JAR is generated for each variant. I'm not sure how dynamically generated per-variant JARs are supposed to be handled if the lint task expects all variants' JARs to be available.

As a hack workaround you could change the lintOptions in app/build.gradle to disable the lint task:

lintOptions {
    checkReleaseBuilds false
}
Umair
  • 1,033
  • 2
  • 10
  • 27
  • 2
    This is dangerous because the apps will still crash after being deployed. The issue should be resolved not swept under the rug. The error is there for a reason – Petro Nov 06 '20 at 19:21