Generate signed apk fails with build\app\intermediates\flutter\profile\libs.jar (The system cannot find the path specified)

I found a fix for this issue as I was searching through various issues people had reported on github regarding this.

This is just a workaround.

You can get two kinds of error. For me the system could not find profile/libs.jar, for some people the error was for debug/libs.jar. If the issue is profile, you should first run your app in profile mode and then Generate signed apk (or build and run in release mode). To run in profile mode use flutter run --profile. There is also a profile option under Run menu in Android Studio.

If the error is about debug/libs.jar, first build the debug version (and also the profile mode) and then try to Generate signed apk. By default, flutter run compiles to debug mode.

This issue evidently arises from the updated Gradle and android studio gradle plugin.

Here is the workaround by Jwiggiff on the github page.

This problem is with latest gradle 4.0.0

Switch from classpath ''

to classpath ''

or classpath '' (Worked for me)

If you don't care about lintOptions you can add this code in app's build.gradle file:

android {
    lintOptions { 
        checkReleaseBuilds false
        abortOnError false