Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter analyze / build fails in GitHub action

When the following action is run, it fails on flutter analyze. If I remove it, it fails later on flutter build. Both commands work fine locally. I understand the message, but fail to grasp what might be wrong with the package path.

GitHub action error:

  flutter analyze
  shell: /bin/bash -e {0}
  env:
    JAVA_HOME_12.0.2_x64: /opt/hostedtoolcache/jdk/12.0.2/x64
    JAVA_HOME: /opt/hostedtoolcache/jdk/12.0.2/x64
    JAVA_HOME_12_0_2_X64: /opt/hostedtoolcache/jdk/12.0.2/x64
    FLUTTER_HOME: /opt/hostedtoolcache/flutter/1.22.5-stable/x64
Analyzing myApp...                                            

  error • Target of URI doesn't exist: 'package:myApp/app.dart' • lib/main.dart:7:8 • uri_does_not_exist
  error • The function 'App' isn't defined • lib/main.dart:38:16 • undefined_function

2 issues found. (ran in 18.4s)
Error: Process completed with exit code 1.

Action source:

name: Flutter Android Test and Build

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

jobs:
  build_android:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Setup Java
        uses: actions/setup-java@v1
        with:
          java-version: "12.x"
      - name: Setup Flutter
        uses: subosito/flutter-action@v1
        with:
          flutter-version: "1.22.5"
      - name: Install Flutter dependencies
        run: flutter pub get
      - name: Format files
        run: flutter format --set-exit-if-changed .
      - name: Analyze code
        run: flutter analyze
      - name: Run tests
        run: flutter test
      - name: Build Android
        run: flutter build apk
like image 344
Lukas Nevosad Avatar asked Oct 20 '25 11:10

Lukas Nevosad


2 Answers

Passing --no-fatal-infos and --no-fatal-warnings as a flag to flutter analyzer worked for me.

Here: flutter analyze --no-fatal-infos --no-fatal-warnings

This is because, unlike dart analyzer, flutter analyzer returns a fatal exit code of 1 regardless of the severity issue (info, warning, error).

Reference

like image 87
Yogesh Parwani Avatar answered Oct 22 '25 04:10

Yogesh Parwani


The issue was in a upper case / lower case file name typo. OSX filesystem is by default case insensitive, while Ubuntu, on which the GitHub Action runs, is not.

like image 42
Lukas Nevosad Avatar answered Oct 22 '25 02:10

Lukas Nevosad