skip to Main Content

Error when building the project with flutter build apk command

I was trying to build my Flutter app and this error shows up:

Unhandled exception:
RangeError (offset): Invalid value: Not in inclusive range 0..1303: 10068
#0      RangeError.checkValueInInterval (dart:core/errors.dart:313)
#1      Source.getLocation (package:kernel/ast.dart:14992)
#2      Component.getLocation (package:kernel/ast.dart:14787)
#3      _getLocationInComponent (package:kernel/ast.dart:15181)
#4      Procedure._getLocationInEnclosingFile (package:kernel/ast.dart:3329)
#5      TreeNode._getLocationInEnclosingFile (package:kernel/ast.dart:207)
#6      TreeNode._getLocationInEnclosingFile (package:kernel/ast.dart:207)
#7      TreeNode.location (package:kernel/ast.dart:203)
#8      localFunctionName (package:vm/transformations/type_flow/utils.dart:449)
#9      SummaryCollector.createSummary (package:vm/transformations/type_flow/summary_collector.dart:628)
#10     TypeFlowAnalysis.getSummary (package:vm/transformations/type_flow/analysis.dart:1782)        
#11     _DirectInvocation._processFunction (package:vm/transformations/type_flow/analysis.dart:398)  
#12     _DirectInvocation.process (package:vm/transformations/type_flow/analysis.dart:287)
#13     _WorkList.processInvocation (package:vm/transformations/type_flow/analysis.dart:1663)        
#14     _WorkList.process (package:vm/transformations/type_flow/analysis.dart:1606)
#15     TypeFlowAnalysis.process (package:vm/transformations/type_flow/analysis.dart:1811)
#16     transformComponent (package:vm/transformations/type_flow/transformer.dart:121)
#17     runGlobalTransformations (package:vm/kernel_front_end.dart:589)
#18     compileToKernel (package:vm/kernel_front_end.dart:489)
<asynchronous suspension>
#19     FrontendCompiler.compile (package:frontend_server/frontend_server.dart:639)
<asynchronous suspension>
#20     starter (package:frontend_server/starter.dart:101)
<asynchronous suspension>
#21     main (file:///C:/b/s/w/ir/x/w/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:13)
<asynchronous suspension>

Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:srcflutterbinflutter.bat'' finished with non-zero exit value 1

* 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 13s
Running Gradle task 'assembleRelease'...                           14.3s
Gradle task assembleRelease failed with exit code 1

I even used flutter clean and flutter pub get and even flutter pub cache repair. Flutter channel is on stable and the latest version. In Debug mode, it is ok and the app runs easily, but when I want to build, I have this problem. I tried many ways but I still have this problem. I even made a new one and added the necessary codes, assets, configurations and packages inside it, but I still had this problem.

2

Answers


  1. This might be a gradle version problem:

    android/gradle/wrapper/gradle-wrapper.properties

    distributionUrl=https://services.gradle.org/distributions/gradle-7.6.3-all.zip

    Try changing the version to 7.6.3 or a compatible version, clean then build.

    Login or Signup to reply.
  2. Try as below:

    1. Something that work for me is: Delete your pubspec.lock, and press ‘Pub Get’ in your pubspec.yaml, it’ll regenerate pubspec.lock file again and should fix the problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search