19
votes
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

11
Did you find any solution? I am facing the same issue.Shahzad Akram
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

11 Answers

39
votes

Step 1. flutter build apk --debug

Step 2. flutter build apk --profile

Step 3. flutter build apk --release

20
votes

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.

14
votes

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

3
votes

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'
2
votes

Running these two commands worked for me:

flutter build apk --profile
flutter build apk --release
1
votes

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
votes

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

0
votes

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

0
votes

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>"?

0
votes

If you see this error because you would like to run certain task on gradle for example lintDebug then you do not need to build the apk that might be slow. You can run this command to execute tasks for generating lint dependencies :

./gradlew generateProfileDependenciesForLint generateReleaseDependenciesForLint

After you run these commands then the lib.jar for each respective build tyoe will be generated and then you can run your gradle task that need lib.jar. It will safe you a lot of time.

-3
votes

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
}