-
Notifications
You must be signed in to change notification settings - Fork 28.4k
flutter build apk fails on an app using Android Gradle plugin 4.0 #58247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Building apk also crashes for me. However, building appbundle works. |
The Android Gradle The As a hack workaround you could change the
|
Hi, |
This comment was marked as abuse.
This comment was marked as abuse.
Same here. Recently updated android studio, android sdk, gradle and flutter, And I no longer able to build release apk |
Hi, |
I wouldn't consider this a solution, but I've found a workaround. I was having the same issue and tried building TL;DR |
I downgraded the android gradle and gradle version, from Android studio Project Structure. And Clean build my project. now it is working. |
That works, thanks! |
@Jwiggiff |
Excellent, thanks! |
I have flavors in my gradle If you have flavors, you have to build to project for every single flavor 3 times, once for debug and once for release, and once for profile |
@ahmaducg does your method help I dont get it exactly what to do cause now I have even upgrade my android studiio to version 4. What else should I do now down grade it ? |
@newbieflutter Downgrading will help, If any of the above methods don't work. You just need to downgrade the Android Gradle and Gradle version, In Project Structure of your android app. |
yep downgrading is the solution for now till this gets fixed. its a bad idea to manually build for each flavor if you say it works. it shouldnt be that way but can be considered a temporary workaround |
This worked perfectly for me |
Even if this worked, some plugins will not work because of R8 and minifying |
It appears that task dependencies aren't wired up in Android Gradle plugin 4.0. While this bug is being fixed and changes rolled out, you can either follow the workarounds: #58247 (comment) or #58247 (comment). Otherwise, continue using the AGP version managed by the Flutter tool as that is the latest version that is known to work well with Flutter. |
Can you expand on this? How do we know which AGP version is managed by the Flutter tool? |
The versions that |
This worked perfectly, thanks |
I'm running on debian 9 and the workaround for downgrading to 3.6.3 , then --profile && --release, works for my machine. |
This is still not working on flutter 2.0.6. |
@niktses This issue was filed over a year ago, and is marked closed. If you are still having a problem, please file a new issue with full details and instructions to reproduce it. Thanks! |
It is marked as closed while it is not fixed and has over a hundred comments. It makes more sense to me to reopen this. And it is a major issue as well. As i see it as of right now no flutter developer can reasonably release their app while having upgraded to flutter 2.0 and gradle 4.0 that has came out a year ago. |
This is an issue that has not been fixed for 1.2 year not a new one. This needs to reopen. Me copy pasting the original into a new issue doesn't seem correct. |
@niktses We would like to resolve your issue, but we can't do that without a fairly detailed explanation of what you are doing. See @blasten's comment above in #58247 (comment). The best place to put that information is in a new issue so that it will be visible to the team. Thanks! |
I really don't get why you don't reopen it. There is not a single word that i would change if i created a new one. Run flutter create counter You can scroll to the top to see more details. Gradle expects a ../libs.jar for every combination of flavor - buildType (in new project needs 3 - release - debug - profile, in my project needs 48 so the above 'solutions' of running each one once is out of the question especially with dev-op). This is not a simple issue as it prevents us from releasing an app as the apk is never generated. |
Hi @zanderso if you review my issue I logged #81974 You will be able to reproduce the issue of Flutter supporting AGP 4.0.1. I am still debugging and trying to figure it out, but the gist of it all is that Flutter Tools does not have a reference to the gradle setup, Gradle seems to be dependant on what location in the directory you run it from. The Command that fails :
In my issue I also show the use of the same Flutter Tools command (flutter run -v) where it can only work manually if run in the android directory, I believe at this point there is something wrong with the way the command is executed via the process manager in flutter tools. Also adding the -p flag to the command and running it manually from the project root directory works. I have tried to manipulate the command on dev channel and it shows that flutter tools cant even read the gradlew tasks from the android directory and reads from the project directory which has a .gradle folder but it only has the boiler plate tasks in it. |
This works, I had to do all 3 builds, THANKS |
Same issues. I have 2 flavors and when building, the error is this: * What went wrong:
Execution failed for task ':app:lintVitalDevelopmentRelease'.
> Could not resolve all artifacts for configuration ':app:productionReleaseRuntimeClasspath'.
> 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/builder/clone/build/app/intermediates/flutter/productionRelease/libs.jar.
> Transform's input file does not exist: /Users/builder/clone/build/app/intermediates/flutter/productionRelease/libs.jar. (See https://issuetracker.google.com/issues/158753935)
This issue is critical since we only need to perform 1 build instead of 2 or 3 (in the case of @niktses, 48). Edit:I'm using the "hack" of calling Edit 2:I got it working using this combo: android/app/build.gradle ...
project.ext.envConfigFiles = [
developmentdebug: ".env.development",
developmentprofile: ".env.development",
developmentrelease: ".env.development",
productiondebug: ".env.production",
productionprofile: ".env.production",
productionrelease: ".env.production",
]
...
// TODO: Temp measure - Add 'checkReleaseBuilds false'
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
... android/build.gradle ...
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2' // <-- using gradle +4.0 instead of downgrade
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
...
}
... *android/gradle/wrapper/gradle-wrapper.properties ...
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip CI/CD (config per flavor) # Build (Debug & profile)
flutter build apk --debug --flavor <flavor>
flutter build apk --profile --flavor <flavor> This config worked without any issue (yet). @niktses you could try using this if works for you. I haven't tried without using debug or profile. Edit 3:We can use the above configuration without this part: CI/CD (config per flavor) # Build (Debug & profile)
flutter build apk --debug --flavor <flavor>
flutter build apk --profile --flavor <flavor> @niktses, you can use the above config omitting the previous part. |
If you don't want to mess with your CI/CD configs then just upgrade your Gradle version: User Android Gradle
And upgrade your Gradle version to |
@pedromassango This did work for me, the approaches from above did not work for me at all. I'm on Flutter
|
It is closed because this is not a Flutter issue but an Android project issue. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Canonical Issue
https://issuetracker.google.com/issues/141126614
Steps to Reproduce
flutter create counter
flutter build apk
Logs
Edit: created an issue against the Jetifier component as suggested by Gradle output https://issuetracker.google.com/u/1/issues/157728192
The text was updated successfully, but these errors were encountered: