Lukas Nevosad
Lukas Nevosad

Reputation: 294

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

Upvotes: 4

Views: 5385

Answers (3)

Moha Krs
Moha Krs

Reputation: 41

I had the same issue like shown here enter image description here

Basically as mentionned above, the imports should be exactly how the folder name is. In my case the import was

import 'app/Localizations/localizations.dart';

But the actual folder name was localisation, so modifying this solved the issue.

import 'app/localizations/localizations.dart';

Upvotes: 0

Yogesh Parwani
Yogesh Parwani

Reputation: 171

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

Upvotes: 7

Lukas Nevosad
Lukas Nevosad

Reputation: 294

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.

Upvotes: 2

Related Questions