Can't run flutter project on emulator – filename too long error

Issue

While running flutter run on emulator in VS Codium I get the following error:

flutter run --debug
Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
startup failed:
/home/damian/dev_tools/flutter/packages/flutter_tools/gradle/build/classes/groovy/main/FlutterPlugin$_addTasksForOutputsAppLinkSettings_closure22$_closure48$_closure50$_closure51$_closure52$_closure53$_closure55$_closure57$_closure58.class (filename too long)

1 error


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gradle:compileGroovy'.
> Compilation failed; see the compiler error output for details.

* 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 31s
Running Gradle task 'assembleDebug'...                             32,6s
Exception: Gradle task assembleDebug failed with exit code 1

I run default project code that is created by default with flutter create projectname.

It also won’t work if I run my own code.

There are lots of files with long names in this dir.
I’m using Linux Mint.
Flutter SDK and Flutter plugin to VS Codium are up to date.

More details:


/home/damian/dev_tools/flutter/packages/flutter_tools/gradle/build/classes/groovy/main/FlutterPlugin$_addTasksForOutputsAppLinkSettings_closure22$_closure48$_closure50$_closure51$_closure52$_closur
e53$_closure55$_closure57$_closure58.class (filename too long)
[  +30 ms] 1 error
[ +122 ms] > Task :gradle:compileGroovy FAILED
[   +2 ms] :gradle:compileGroovy (Thread[included builds,5,main]) completed. Took 17.064 secs.
[        ] FAILURE: Build failed with an exception.
[   +6 ms] * What went wrong:
[        ] Execution failed for task ':gradle:compileGroovy'.
[        ] > Compilation failed; see the compiler error output for details.
[        ] * Try:
[        ] > Run with --debug option to get more log output.
[   +7 ms] > Run with --scan to get full insights.
[   +1 ms] * Exception is:
[        ] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':gradle:compileGroovy'.
[   +5 ms]      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:142)
[        ]      at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
[   +3 ms]      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:140)
[   +2 ms]      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:128)
[  +10 ms]      at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
[        ]      at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
[        ]      at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
[   +2 ms]      at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
[        ]      at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
[   +1 ms]      at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
[   +6 ms]      at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
[   +4 ms]      at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
[        ]      at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
[   +2 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
[  +12 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
[   +7 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
[   +7 ms]      at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
[   +6 ms]      at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:69)
[        ]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:327)
[        ]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:314)
[   +1 ms]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:307)
[   +3 ms]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:293)
[        ]      at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:417)
[        ]      at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:339)
[        ]      at org.gradle.execution.plan.DefaultPlanExecutor.process(DefaultPlanExecutor.java:96)
[        ]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph.executeWithServices(DefaultTaskExecutionGraph.java:140)
[        ]      at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph.execute(DefaultTaskExecutionGraph.java:125)
[        ]      at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:39)
[   +8 ms]      at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:51)
[   +1 ms]      at org.gradle.execution.BuildOperationFiringBuildWorkerExecutor$ExecuteTasks.call(BuildOperationFiringBuildWorkerExecutor.java:54)
[        ]      at org.gradle.execution.BuildOperationFiringBuildWorkerExecutor$ExecuteTasks.call(BuildOperationFiringBuildWorkerExecutor.java:43)
[   +4 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
[   +1 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
[  +11 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
[   +5 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
[   +4 ms]      at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
[        ]      at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
[        ]      at org.gradle.execution.BuildOperationFiringBuildWorkerExecutor.execute(BuildOperationFiringBuildWorkerExecutor.java:40)
[        ]      at org.gradle.internal.build.DefaultBuildLifecycleController.lambda$executeTasks$7(DefaultBuildLifecycleController.java:161)
[        ]      at org.gradle.internal.model.StateTransitionController.doTransition(StateTransitionController.java:247)
[        ]      at org.gradle.internal.model.StateTransitionController.lambda$tryTransition$7(StateTransitionController.java:174)
[        ]      at org.gradle.internal.work.DefaultSynchronizer.withLock(DefaultSynchronizer.java:44)
[        ]      at org.gradle.internal.model.StateTransitionController.tryTransition(StateTransitionController.java:174)
[  +16 ms]      at org.gradle.internal.build.DefaultBuildLifecycleController.executeTasks(DefaultBuildLifecycleController.java:161)
[        ]      at org.gradle.internal.build.DefaultBuildWorkGraphController$DefaultBuildWorkGraph.runWork(DefaultBuildWorkGraphController.java:156)
[        ]      at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:249)
[        ]      at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:109)
[        ]      at org.gradle.composite.internal.DefaultBuildController.doRun(DefaultBuildController.java:164)
[        ]      at org.gradle.composite.internal.DefaultBuildController.access$000(DefaultBuildController.java:45)
[  +32 ms]      at org.gradle.composite.internal.DefaultBuildController$BuildOpRunnable.run(DefaultBuildController.java:183)
[        ]      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[        ]      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[        ]      at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
[        ]      at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
[        ]      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[        ]      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[        ]      at java.base/java.lang.Thread.run(Thread.java:833)
[        ] Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
[  +14 ms]      at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:276)
[        ]      at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:64)
[        ]      at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:97)
[        ]      at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:76)
[        ]      at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
[        ]      at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
[  +19 ms]      at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
[        ]      at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
[        ]      at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
[        ]      at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
[        ]      at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
[        ]      at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
[        ]      at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:87)
[        ]      at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:56)
[        ]      at org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
[        ]      at org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
[        ]      at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
[        ]      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[   +2 ms]      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
[        ]      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[        ]      at java.base/java.lang.reflect.Method.invoke(Method.java:568)
[        ]      at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
[        ]      at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
[        ]      at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
[        ]      at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
[        ]      at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
[        ]      at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
[        ]      at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
[        ]      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[        ]      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[        ]      at java.base/java.lang.Thread.run(Thread.java:833)
[        ] * Get more help at https://help.gradle.org
[  +10 ms] BUILD FAILED in 20s
[   +1 ms] 1 actionable task: 1 executed
[        ] Some of the file system contents retained in the virtual file system are on file systems that Gradle doesn't support watching. The relevant state was discarded to ensure changes to these
locations are properly detected. You can override this by explicitly enabling file system watching.
[  +42 ms] Stopped 1 worker daemon(s).
[ +642 ms] Running Gradle task 'assembleDebug'... (completed in 21,2s)
[+6474 ms] Exception: Gradle task assembleDebug failed with exit code 1
[   +4 ms] "flutter run" took 30 295ms.
[   +5 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:752:9)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1350:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:348:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:294:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:112:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:90:3)
           <asynchronous suspension>

Tried reinstalling plugin and reinstalling flutter SDK – no effect. I also tried cleaning and rebuilding project or creating new project – no effect.

EDIT Tried using Android Studio instead – also won’t work.

Solution

This problem is caused by a combination of multiple things:

  1. Your file system (encrypted ext4 using eCryptFS) limiting filenames to ~143 characters
  2. The compiler inside gradle generating long file names for nested closures
  3. Recent changes in flutter 3.16 causing the function addTasksForOutputsAppLinkSettings to use many nested closures.

In short, this means: You cannot compile a flutter 3.16 project using standard gradle settings on an encrypted Linux Mint file system.


Unfortunately, there is no easy fix. You have the following options:

  1. Disabling encryption of your file system or moving your flutter project to a non-encrypted part of your disk
  2. Changing the internals of the groovy compiler to use shorter file names for generated files.
  3. Raise the issue with the flutter team and ask for a refactoring of the recent 3.16 changes that would result in a lower amount of nested closures.

Number 3 sounds like a straightforward fix, but would only be temporary. Someone could
could (un)knowingly reintroduce a high amount of nested closures in the next update and break builds on encrypted file systems again. A permanent fix would require long-term support from the flutter maintainers.

Number 2 is a promising approach since it would offer a long-term fix. But this requires changes to the compiler which could take some while.

So what you are left with on the short term: Move your project (or at least the build output folder) to a non-encrypted part of your disk

Answered By – jraufeisen

Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *