How to Fix “Gradle build failed to produce an Android bundle package”

Status: draft

There is a multitude of reasons for which you might encounter a frustrating problem like Gradle build failed to produce an Android bundle package.

As of @Tam Tam Tam's answer, first try to update your gradle and android gradle plugin to a latest version.

If that does not fix your problem, then try to disable all the different architectures and set universalApk to false in your android/app/build.grade in splits section. Put something like this:

splits {
        abi {
            enable true
            reset()
            // include 'x86', 'armeabi-v7a', 'x86_64'
            universalApk false
        }
    }

This suggestion was provided here:
https://github.com/flutter/flutter/issues/27462#issuecomment-507229131

It happens because gradle generates the apk following a convention, eg, app-<architecture-name>.apk, which is not understandable by flutter, it expects apk names in another format, eg, simply app.apk. Disabling all different architectures name bring them to a common understanding 🙂

If that is also not work, then try to remember if you change your package name com.example.packagename to something your own personal like com.mywebsite.packagename. If you have done it, then you probably changed it everywhere needed, for example, in build.gradles and AndroidManifest.xml but you might forgot to change it in your java (or kotlin class).

To make your new package name works, you also have to change the package name in src/main/java/com/mywebsite/packagename/MainActivity.java (in case of kotlin, it's src/main/kotlin/com/mywebsite/packagename/MainActivity.kt)

I hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top