androidflutterdart

Flutter build failing with gradle error even after fixing


I've been trying to build an apk, tho working perfectly in my ios emulator.It's not building for apk and i got the error below:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
   > Compilation failed to complete, origin: /Users/mac/Documents/flutter/myvidcall/build/record_android/intermediates/runtime_library_classes_jar/release/classes.jar:com/llfbandit/record/record/format/Format.class

* 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 4m 45s
Running Gradle task 'assembleRelease'...                          286.5s

┌─ Flutter Fix ──────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on                                             │
│ https://kotlinlang.org/docs/releases.html#release-details, then update │
│ /Users/mac/Documents/flutter/myvidcall/android/build.gradle:           │
│ ext.kotlin_version = '<latest-version>'                                │
└────────────────────────────────────────────────────────────────────────┘
Gradle task assembleRelease failed with exit code 1

I upgraded the gradle several times top the latest, same issue. I tried 2.0.0 same issue and a tried a little lesser too, same issue.

below is my gradle.

...
    buildTypes {
        release {
            signingConfig signingConfigs.debug
             // Enable shrinking, obfuscation, and code optimization for the release build
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            // Add this block to exclude problematic classes from minification
            proguardFiles 'proguard-rules.pro'
        }
    }
    ...

Solution

  • This isn't a kotlin version problem. You can try with latest kotlin version and the same error will happen.

    The problem is related to proguard-rules.pro file. You need to edit it. If this error is occured by some libraries like razorpay, you can get the proguard rules from their documentaation.