subosito / flutter-action

Flutter environment for use in GitHub Actions. It works on Linux, Windows, and macOS.
MIT License
2.16k stars 193 forks source link

flutter build web is not compiling #248

Closed naveenbharadwaj19 closed 9 months ago

naveenbharadwaj19 commented 9 months ago

I have five Flutter projects, "A," "B," "C," "D," and "E." I'm using the same workflow for all these apps. When running flutter build web or flutter build web --profile, I encounter compilation errors. Surprisingly, it works fine for "A," "B," and "C," but it's not working for "D" and "E." I can successfully create a web bundle on my local machine for all the apps.

Code:

- name: Set up Flutter
  uses: subosito/flutter-action@v2
  with:
    flutter-version: "3.10.0"

- name: Build and Deploy
  run: |
    if [[ ${{ github.ref }} == "refs/heads/main" ]]; then
      dart run build_runner build --delete-conflicting-outputs
      flutter build web
    elif [[ ${{ github.ref }} == "refs/heads/sandbox" ]]; then
      dart run build_runner build --delete-conflicting-outputs
      flutter build web --profile
    fi
Error log ``` Compiling lib/main.dart for the Web... Target dart2js failed: Exception: lib/main.dart:3:8: Error: Error when reading 'lib/src/utils/globals.dart': Error reading 'lib/src/utils/globals.dart' (No such file or directory) import 'package:chesa_dental_doctor/src/utils/globals.dart'; ^ lib/main.dart:11:8: Error: Error when reading 'lib/src/utils/center.dart': Error reading 'lib/src/utils/center.dart' (No such file or directory) import 'src/utils/center.dart'; ^ lib/main.dart:12:8: Error: Error when reading 'lib/src/utils/custom_logger.dart': Error reading 'lib/src/utils/custom_logger.dart' (No such file or directory) import 'src/utils/custom_logger.dart'; ^ lib/src/services/notification_services/f_c_m_service.dart:3:8: Error: Error when reading 'lib/src/utils/custom_logger.dart': Error reading 'lib/src/utils/custom_logger.dart' (No such file or directory) import '../../utils/custom_logger.dart'; ^ lib/main.dart:13:8: Error: Error when reading 'lib/src/utils/jwt_token.dart': Error reading 'lib/src/utils/jwt_token.dart' (No such file or directory) import 'src/utils/jwt_token.dart'; ^ lib/main.dart:14:8: Error: Error when reading 'lib/src/utils/member.dart': Error reading 'lib/src/utils/member.dart' (No such file or directory) import 'src/utils/member.dart'; ^ lib/main.dart:15:8: Error: Error when reading 'lib/src/utils/string_extension.dart': Error reading 'lib/src/utils/string_extension.dart' (No such file or directory) import 'src/utils/string_extension.dart'; ^ lib/src/ui/splash_u_i/splash_u_i.dart:8:8: Error: Error when reading 'lib/src/utils/jwt_token.dart': Error reading 'lib/src/utils/jwt_token.dart' (No such file or directory) import '../../utils/jwt_token.dart'; ^ lib/app.dart:6:8: Error: Error when reading 'lib/src/routes/routes.dart': Error reading 'lib/src/routes/routes.dart' (No such file or directory) import 'src/routes/routes.dart'; ^ lib/app.dart:8:8: Error: Error when reading 'lib/src/utils/theme.dart': Error reading 'lib/src/utils/theme.dart' (No such file or directory) import 'src/utils/theme.dart'; ^ lib/src/ui/splash_u_i/splash_u_i.dart:9:8: Error: Error when reading 'lib/src/utils/theme.dart': Error reading 'lib/src/utils/theme.dart' (No such file or directory) import '../../utils/theme.dart'; ^ lib/src/services/local_storage_services/local_storage_service.dart:3:8: Error: Error when reading 'lib/src/widgets/logger.dart': Error reading 'lib/src/widgets/logger.dart' (No such file or directory) import '../../widgets/logger.dart'; ^ lib/src/services/auth_services/auth_service.dart:16:8: Error: Error when reading 'lib/src/utils/globals.dart': Error reading 'lib/src/utils/globals.dart' (No such file or directory) import '../../utils/globals.dart'; lib/src/services/apis/api.dart:139:25: Error: Undefined name 'GlobalVar'. String apiAddress = GlobalVar.apiUrl! + apiEndPoint; ^^^^^^^^^ lib/src/services/apis/api.dart:143:22: Error: Undefined name 'jwtToken'. String token = jwtToken!; ^^^^^^^^ Error: Compilation failed. #0 Dart2JSTarget.build (package:flutter_tools/src/build_system/targets/web.dart:212:7) #1 _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:[847](https://github.com/Swevens-Immersive/chesa-dental-doctor/actions/runs/6312204211/job/17137761810#step:5:848):9) #2 Future.wait. (dart:async/future.dart:525:21) #3 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:785:32) #4 Future.wait. (dart:async/future.dart:525:21) #5 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:785:32) #6 FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:614:16) #7 WebBuilder.buildWeb (package:flutter_tools/src/web/compile.dart:81:34) #8 BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:191:5) #9 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1336:27) #10 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #11 CommandRunner.runCommand (package:args/command_runner.dart:212:13) #12 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:296:9) #13 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #14 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:244:5) #15 run.. (package:flutter_tools/runner.dart:91:9) #16 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #17 main (package:flutter_tools/executable.dart:91:3) Exception: Failed to compile application for the Web. Compiling lib/main.dart for the Web... 15.0s The Flutter CLI developer tool uses Google Analytics to report usage and diagnostic data along with package dependencies, and crash reporting to send basic crash reports. This data is used to help improve the Dart platform, Flutter framework, and related tools. Telemetry is not sent on the very first run. To disable reporting of telemetry, run this terminal command: flutter --disable-telemetry. If you opt out of telemetry, an opt-out event will be sent, and then no further information will be sent. This data is collected in accordance with the Google Privacy Policy (https://policies.google.com/privacy). Error: Process completed with exit code 1. ```

Tried flutter clean, flutter pub get. Still same issue

naveenbharadwaj19 commented 9 months ago

Oops, I figured out there is a little typo in the import, and I have fixed it.