dirkbo
dirkbo

Reputation: 673

flutter 1.9.1+hotfix.2 - build appbundle failing, but actually producing an appbundle

Since upgrading flutter 1.9.1+hotfix.2 to, when I run flutter build appbundle, flutter finishes with an error:

Initializing gradle...                                              0,9s
Resolving dependencies...                                           3,6s
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done                       114,5s
Gradle build failed to produce an Android bundle package.

But actually it did Produce a valid appbundle, flutter build appbundle -v finishes with:

[   +2 ms] 161 actionable tasks: 5 executed, 156 up-to-date
[ +361 ms] Running Gradle task 'bundleRelease'... (completed in 75,1s)
[   +7 ms] "flutter appbundle" took 80.137ms.
Gradle build failed to produce an Android bundle package.

#0      throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1      _buildGradleProjectV2 (package:flutter_tools/src/android/gradle.dart:780:7)
#2      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#3      _rootRunUnary (dart:async/zone.dart:1132:38)
#4      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#5      _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#6      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#7      Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#8      Future._completeWithValue (dart:async/future_impl.dart:522:5)
#9      _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#10     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)

It looks like gradle crashes after finishing the appbundle. Anyone have the same Problem or any Ideas?

My Flutter doctor: Flutter version 1.9.1+hotfix.2 at C:\src\flutter • Framework revision 2d2a1ffec9 (8 days ago), 2019-09-06 18:39:49 -0700 • Engine revision b863200c37 • Dart version 2.5.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\dirkb\AppData\Local\Android\sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03) • All Android licenses accepted.

[√] Android Studio (version 3.5) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 39.0.3 • Dart plugin version 191.8423 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

Upvotes: 3

Views: 1811

Answers (4)

Eugene Debrah
Eugene Debrah

Reputation: 3

I encountered this problem and this is what I did:

1.Deleted ".idea" folder and "build" folder as well as "pubspec-lock" file. 2.Then run flutter pub get in my console

It Should Work

Upvotes: 0

Markus Schmidt
Markus Schmidt

Reputation: 462

It is not weird, it is a bug. gradle displays an error message even if everything went well.

SOLUTION

Edit your build.gradle and change

classpath 'com.android.tools.build:gradle:3.5.0'

to:

classpath 'com.android.tools.build:gradle:3.4.2'

DETAILS

I encountered two bugs with tools.build:gradle:3.5.0:

First of all, local.properties is re-build every time you compile, (don't it check-in!)

a) with gradle, using flutter build appbundle --release -v the result is sdk.dir=C:\\....\\AppData\\Local\\Android\\Sdk (no matter which tool version)

b) with IntelliJ is was sdk.dir=C:/..../AppData/Local/Android/Sdk

Unfortunately, tools.build:gradle:3.5.0 fail when reading the path they create, where tools.build:gradle:3.4.2 work.

I you want to use tools v3.5.0 do this:

set ANDROID_HOME=C:/Users/msc/AppData/Local/Android/Sdk (slash, not backslash, on Windows!!)

After that, gradle did the build and finished with Gradle build failed to produce an Android bundle package. which is weird because gradle actually did the full job. The file is there: \build\app\outputs\bundle\release\app-release.aab.

So, error message without error?

Obviously gradle.tools v3.5.0 have problems with path names, at least on Windows.

And... just another tip: check your android\key.properties file and make sure the storeFile= setting is correct.

key.properties storeFile=c:/pathToMyKeyStore.jks

NOTE: You should use / in the path, not \

Upvotes: 4

Elialber Lopes
Elialber Lopes

Reputation: 663

On the path to setting is android/app/build.gradle:

try this one: minifyEnabled false

Upvotes: 0

LarssonK
LarssonK

Reputation: 3053

I came across this problem as well. You can't create an app bundle in flutter at the moment, there is a bug with the file naming when the aab is created. Just use Android Studio to create the aab file.

Build > Build APK/Bundle > Build Bundle(s)

Edit: Bonus, not asked but might be helpful to know if anyone doesn't already know. I had some users unable to use my app. Add the following to your gradle file to ensure the app bundle includes the following libraries.

android {
    defaultConfig {
        //add the following
        ndk {
            abiFilters "x86", "x86_64", "armeabi", "armeabi-v7a", "arm64-v8a"
        }
    }
}

Upvotes: 1

Related Questions