AppCenter build crashes when building Flutter Android app

837

Solution 1

I was also facing similar issue. An alternative way is just to release an apk to the release section of the appcenter.

Solution 2

Is flutter build apk --release working locally? Which build settings you are using in appcenter? Did you updated your .gitignore, like in the tutorial?

Please try to provide some more information. Had a similar problem and solved it by adding the pre-post.sh but it seems you are having a different problem.

Try flutter clean and flutter build. Then try to push and build again.

Share:
837
Ketobomb
Author by

Ketobomb

Updated on December 13, 2022

Comments

  • Ketobomb
    Ketobomb over 1 year

    I'm buiding a Flutter Android app with AppCenter build.

    I have the following build script taken from here

    #!/usr/bin/env bash
    #Place this script in project/android/app/
    cd ..
    # fail if any command fails
    set -e
    # debug log
    set -x
    cd ..
    git clone -b dev https://github.com/flutter/flutter.git
    export PATH=`pwd`/flutter/bin:$PATH
    flutter doctor
    echo "Installed flutter to `pwd`/flutter"
    flutter build apk --release
    #copy the APK where AppCenter will find it
    mkdir -p android/app/build/outputs/apk/; mv build/app/outputs/apk/release/app-release.apk $_
    

    Here is an excerpt of the build log:

    ...    
    Downloading ios-deploy...                                           0.4s
        Doctor summary (to see all details, run flutter doctor -v):
        [✓] Flutter (Channel dev, v1.9.7, on Mac OS X 10.14.6 18G87, locale en)
        [!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
            ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
        [✓] Xcode - develop for iOS and macOS (Xcode 10.3)
        [!] Android Studio (not installed)
        [!] Connected device
            ! No devices available
    
        ! Doctor found issues in 3 categories.
        ++ pwd
        + echo 'Installed flutter to /Users/vsts/agent/2.155.1/work/1/s/flutter'
        + flutter build apk --release
        Installed flutter to /Users/vsts/agent/2.155.1/work/1/s/flutter
        Running "flutter pub get" in s...                                   4.1s
        You are building a fat APK that includes binaries for android-arm, android-arm64.
        If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
            To generate an app bundle, run:
                flutter build appbundle --target-platform android-arm,android-arm64
                Learn more on: https://developer.android.com/guide/app-bundle
            To split the APKs per ABI, run:
                flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
                Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
        Initializing gradle...                                          
    
        Sending crash report to Google.
    
    ...
    

    Looks like AppCenter cannot initialize Gradle. Any suggestions? .gitignore file:

    # Android related
    #**/android/**/gradle-wrapper.jar
    **/android/.gradle
    **/android/captures/
    #**/android/gradlew
    #**/android/gradlew.bat
    **/android/local.properties
    **/android/**/GeneratedPluginRegistrant.java
    
  • Ketobomb
    Ketobomb over 4 years
    Yes. I did update the .gignore. Flutter build apk --release is working locally. flutter clean and flutter build apk run locally and pushed. AppCenter build fails...
  • Abdullah Khan
    Abdullah Khan about 4 years
    Did you find the solution? I need help? Same issue
  • Abdullah Khan
    Abdullah Khan about 4 years
    Did you find the solution? I need help? Same issue
  • eddyoc
    eddyoc almost 4 years
    This is indeed a workaround, but for those of us trying to setup a release pipeline not a solution. It would be good to know the eventual resolution from those who have solved this problem.
  • mfrischbutter
    mfrischbutter almost 4 years
    @AbdullahKhan check if your gradle files are pushed properly after editing the .gitignore file.