Skip to content

flutter build apk fails on an app using Android Gradle plugin 4.0 #58247

@MaikuB

Description

@MaikuB
Contributor

Canonical Issue

https://issuetracker.google.com/issues/141126614

Steps to Reproduce

  1. Run flutter create counter
  2. Update the app to use Android Gradle plugin 4.0.0
  3. Run flutter build apk

Logs

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: /Users/michaelbui/Projects/counter/build/app/intermediates/flutter/debug/libs.jar.
         > Failed to transform '/Users/michaelbui/Projects/counter/build/app/intermediates/flutter/debug/libs.jar' using Jetifier. Reason: FileNotFoundException, message: /Users/michaelbui/Projects/counter/build/app/intermediates/flutter/debug/libs.jar (No such file or directory). (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
[✓] Flutter (Channel stable, v1.17.2, on Mac OS X 10.15.5 19F96, locale en-AU)
    • Flutter version 1.17.2 at /Users/michaelbui/flutter
    • Framework revision 5f21edf8b6 (20 hours ago), 2020-05-28 12:44:12 -0700
    • Engine revision b851c71829
    • Dart version 2.8.3

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/michaelbui/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.1

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.45.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.2

Edit: created an issue against the Jetifier component as suggested by Gradle output https://issuetracker.google.com/u/1/issues/157728192

Activity

Zazo032

Zazo032 commented on May 29, 2020

@Zazo032
Contributor

Building apk also crashes for me. However, building appbundle works.
Running with --release also crashes, but if you run --debug and then --release, it does seem to work (weird one). After succesfully running with --release, you'll be able to build apk.

jason-simmons

jason-simmons commented on May 30, 2020

@jason-simmons
Member

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
}

@blasten

newbieflutter

newbieflutter commented on May 31, 2020

@newbieflutter

Hi,
It also fails on my side I tried first --debug then --release it fails. I tried checkReleaseBuilds false but many plugin fails like shared_preferences, maps etc all fail to work. What is the best solution ?

sgehrman

sgehrman commented on May 31, 2020

@sgehrman
Malik056

Malik056 commented on May 31, 2020

@Malik056

Same here. Recently updated android studio, android sdk, gradle and flutter, And I no longer able to build release apk

newbieflutter

newbieflutter commented on May 31, 2020

@newbieflutter

Hi,
Looks like this is a big issue then. I upgrade all too. Any one found any solution?

Jwiggiff

Jwiggiff commented on May 31, 2020

@Jwiggiff

I wouldn't consider this a solution, but I've found a workaround. 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.

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

Malik056

Malik056 commented on May 31, 2020

@Malik056

I downgraded the android gradle and gradle version, from Android studio Project Structure. And Clean build my project. now it is working.

amelnikov78

amelnikov78 commented on Jun 1, 2020

@amelnikov78

@Jwiggiff

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

That works, thanks!

added
customer: crowdAffects or could affect many people, though not necessarily a specific customer.
platform-androidAndroid applications specifically
c: crashStack traces logged to the console
t: gradle"flutter build" and "flutter run" on Android
toolAffects the "flutter" command-line tool. See also t: labels.
on Jun 1, 2020

191 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.dependency: androidAndroid team may need to help usfound in release: 1.21Found to occur in 1.21has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on AndroidtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Relationships

None yet

    Participants

    @gustav3d@xster@sgehrman@tenaz3@jmagman

    Issue actions

      flutter build apk fails on an app using Android Gradle plugin 4.0 · Issue #58247 · flutter/flutter