Skip to content

Gradle build failed to produce an .apk file #45346

Closed

Description

@ThomasValois

Error Message

Gradle build failed to produce an .apk file. It's likely that this file was generated under C:\Users\...\build, but the tool couldn't find it.

Issue

I've tried moving my Flutter app to AndroidX after it kept prompting me but after doing so the above error message keeps appearing and now I can't even run my app. Any assistance on what can be done for this?

Tried

  • Flutter clean
  • New emulator
  • Disabling AndroidX (doesn't work)

Flutter Doctor --verbose

[√] Flutter (Channel master, v1.12.6-pre.15, on Microsoft Windows [Version 10.0.18363.476], locale en-GB)
    • Flutter version 1.12.6-pre.15 at C:\Android\flutter
    • Framework revision 43a8a1902e (5 hours ago), 2019-11-21 12:09:43 +0100
    • Engine revision 7a77e3625d
    • Dart version 2.7.0
 


[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Android\
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = C:\Android
    • ANDROID_SDK_ROOT = C:\Android\sdk
    • Java binary at: C:\Android\openjdk\bin\java
    • Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_202-b08)
    • All Android licenses accepted.

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

[√] VS Code (version 1.40.1)
    • VS Code at C:\Users\tvalois\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.6.0

[√] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

Full Issue

The plugin "cloud_firestore" is built using an older version of the Android plugin API which assumes that it's running in a full-Flutter environment. It may have undefined behaviors when Flutter is integrated into an existing app as a module.
The plugin can be updated to the v2 Android Plugin APIs by following 
https://flutter.dev/go/android-plugin-migration.
Launching lib\main.dart on Android SDK built for x86 in debug mode...

Note: C:\Android\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.10+2\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Android\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.10+2\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\Android\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_analytics-5.0.6\android\src\main\java\io\flutter\plugins\firebaseanalytics\FirebaseAnalyticsPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Android\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.4.1+5\android\src\main\java\io\flutter\plugins\firebase\core\FirebaseCorePlugin.java uses or overrides a deprecated API.

Gradle build failed to produce an .apk file. It's likely that this file was generated under C:\Users\...\build, but the tool couldn't find it.

Activity

  1. iapicca commented on Nov 22, 2019

    @iapicca

    Hi @ThomasValois
    the error seems caused by the cloud_firestore FlutterFire plugin,
    please open the issue in the dedicated github.
    Closing, as this isn't an issue with Flutter itself,
    if you disagree please write in the comments and I will reopen it
    thank you

  2. DyaryRaoof commented on Dec 5, 2019

    @DyaryRaoof

    Having the same issue on android , I am only using firebase_messaging plugin not cloud_firestore

  3. migalv commented on Dec 27, 2019

    @migalv

    Same issue here. I'm just trying to run on profile mode, but it throws this error:

    Running Gradle task 'assembleProfile'... Done                     597,5s (!)
    Gradle build failed to produce an .apk file. It's likely that this file was generated under ...
    

    It also takes ages to build for some reason :/

    I don't think it has anything to do with the cloud_firestore, because those are just Xlint warnings.

    I never had this issue, I believe it could be related to the upgrade to Flutter v1.12, I updated recently

    SOLVED

    I solved my problem. This was caused because I was not entering the --flavor argument.
    Maybe it can be yours too, check if you have flavors activated.

    Maybe more information about this error in the future?

  4. mobile-dualbootpartners commented on Jan 16, 2020

    @mobile-dualbootpartners

    I had the same problem on the Mac and solution for was add to android/app/build.gradle:

    android {
         ... // Your android config
    
        buildTypes {
            release {
                signingConfig signingConfigs.debug
            }
        }
    }
    
  5. bangonkali commented on Jan 20, 2020

    @bangonkali

    I had the same problem on the Mac and solution for was add to android/app/build.gradle:

    android {
         ... // Your android config
    
        buildTypes {
            release {
                signingConfig signingConfigs.debug
            }
        }
    }
    

    This worked for me. I have been looking around for the solution to this problem for quite a while now. Thanks!

  6. iapicca commented on Feb 5, 2020

    @iapicca

    Could everyone who still has this problem please file a new issue with the exact descriptions what happens, logs and the output of 'flutter doctor -v' please.
    All system setups can be slightly different so it's always better to open new issues and reference related issues.

  7. superyyl commented on Mar 31, 2020

    @superyyl

    I solved this problem.
    To run flutter clean, will clean the build folder.

  8. lock commented on Apr 15, 2020

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked and limited conversation to collaborators on Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions