Home > Software engineering >  I cant build apk flutter app. Error: FAILURE: Build failed with an exception
I cant build apk flutter app. Error: FAILURE: Build failed with an exception

Time:12-24

I wanted to test my flutter app in phone. So i tried build an apk. I ran this in app files:

flutter build apk --split-per-abi

results:

 FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Can Ahmet\StudioProjects\myapp\myapp\android\app\build.gradle' line: 26

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not open cp_dsl generic class cache for script 'C:\SRC\flutter\packages\flutter_tools\gradle\flutter.gradle' (C:\Users\Can Ahmet\.gradle\caches\7.4\scripts\926y60l3pifaoznpot8d19f2t).
   > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63

* 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

BU�LD FAILED in 14s
Running Gradle task 'assembleRelease'...                           17,5s
Gradle task assembleRelease failed with exit code 1

How can i solve that?

I tried run with --stacktrace option to get the stack trace. result:

Could not find an option named "stacktrace".


Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.

I tried run with --debug option to get more log output. result:

'build' is not recognized as an internal or external command,
operable program or batch file.

Did i wrong write? Run images

CodePudding user response:

try this flutter clean, flutter packages get ,flutter build apk --release if this steps doesn't work you can try to use lower version of gradle.

CodePudding user response:

I had Java 19 and gradle 6.7. Those are not compatible. You can learn Compatibility Matrix here

I used java 19 and gradle 7.6. Those are compatible. That is worked. But now i have new problem Flutter Error (while build apk) : FAILURE: Build failed with an exception. > Could not resolve all files for configuration ':classpath'

  • Related