53

I just updated my Android studio to the version 2021.1.1 Canary 12. After struggling to make it work, I had to also upgrade my Gradle and Gradle plugin to 7.0.2. Now I can compile my project and launch my app on my mobile, everything is working. But when I try to generate a Signed APK, I get a strange message after building telling me: APK(s) generated successfully for module 'android-mobile-app-XXXX.app' with 0 build variants:

enter image description here

Even though the build seem to be successful I cannot find the generated APK anywhere (and considering the time it takes to give me that error, I don't even think it is building anything). Now, I have been generating an APK every week for years now, so I know my way around the folders, the different build variant output folders etc... Nothing changed in my way of generating an APK. I do it via AS and follow the very standard procedure.

Can someone point to me what am I missing here? I assume there is a way to select a specific build variant when generating a signed APK, how does it works?

PS: Obviously, I am selecting my variant here during the process: enter image description here

PS2: I can generate a debug APK without any issue whatsoever.

2
  • Have you solved this issue?
    – c-an
    Oct 21, 2022 at 6:12
  • I faced the same issue with the latest AS while generating the Live release APK. So after the generated success message, I just performed the Build -> CLEAN project and boom! I see the APKs now in the file system and as well in the AS. Hope it helps you too.
    – Harpreet
    Feb 2 at 20:19

13 Answers 13

83

There is an issue with the new Android Studio Bumblebee it says "APK(s) generated successfully for module 'PrasavWatch.app' with 0 build variants:" but it builds APK as well in the desired package and you can find it there..

2
  • 2
    I confirm that all apk's are built. Feb 2, 2022 at 10:32
  • true, it is under module/variant/module-variant.apk
    – htafoya
    Apr 5, 2022 at 22:02
43

OK so there is a bug in this version of Android Studio. When you build an APK it does not link properly to the file but it DOES IN FACT BUILD IT. If you build an AAB file and click the locate button, the APK file will be next to it. Follow these steps to reproduce:

  1. Build APK

enter image description here

  1. Verify it is built with 0 output variants

enter image description here

  1. Build app bundle

enter image description here

  1. Click on link for built variant in step three

enter image description here

  1. In the opened folder / directory you will see both the newly generated AAB and APK files

enter image description here

3
  • work for me! so weird
    – The MJ
    Apr 25, 2022 at 13:32
  • It's there but it generates broken apk file.
    – c-an
    Oct 21, 2022 at 3:29
  • @c-an not sure what is going on. Try doing it again. Make sure to make APK with bin folder running an APK that was originally deployed to a device instead of an emulator. Oct 22, 2022 at 19:31
5

It's a issue in new android studio. But this will create apk in desired folder.

Kindly check that folder for apk.

3
  • Yes. It is generating. Thank you
    – Reddy Raaz
    Jul 13, 2022 at 8:54
  • 1
    It's there but it generates broken apk file.
    – c-an
    Oct 21, 2022 at 3:29
  • than try to generate it again, if it fails than check your signin configs Oct 21, 2022 at 6:20
3

I had gradle version 7.0.2

error with 0 build variants: 

was showing Upgrading to 7.2.0 resolved this issue.

Then I faced another issue that i had to upgrade prefs to:

classpath "com.google.firebase:perf-plugin:1.4.1"
3

Updating my Gradle from 6.7.1 to 7.2 fixed my problem in Android Studio Bumblebee

Note: This updated version of Gradle will require Java 11 JDK to run

3

I had this problem recently when building the same project between two computers running different versions of Android Studio. As I discovered later, the APK still builds. Android Studio just can't seem to figure that out. At least, the newer versions can't.

I found my signed release APK at app/release in the project directory. I would advise anyone having this issue to check there. For debug builds, try checking app/debug.

2

Update gradle to the latest version, this will fix this issue

1

After a few days of struggle, I ended up switching to Bundle. It achieves the same purpose for me and it actually works so... That's my solution here.

7
  • What if you want to give or test a release apk? just updated to stable 2021.1.1 bumblebee and i'm having the same issue. Jan 31, 2022 at 7:01
  • 2
    I had this today, bumblebee version of Android Studio. This is a workaround... Generate the Bundle and open the folder of the aab generated. Generate your signed APK, although it says "0 build variants" the APK will be in the above folder. Jan 31, 2022 at 11:11
  • @MarkSheekey Did you find any solution? I am still facing the same issue Jan 31, 2022 at 13:44
  • I have the same issue here. I used command line to assemble my APK, and then signed it with command line too : developer.android.com/studio/build/building-cmdline I hope to find a solution to fix this... Feb 1, 2022 at 9:23
  • 1
    Currently, we can build an apk manually using the following command ./gradlew assembleDebug or ./gradlew assembleRelease. As the first step you should open your Termail tab at the bottom part of the Android Studio, move to the root directory of your project using the cd <where> command, run one of the commands above.
    – Alexandr
    Feb 1, 2022 at 17:00
1

I had the same issue and when it builds with 0 variant, it generates an APK file but it's broken(Not installable).

I solved this issue with upgrading gradle version.

to this:

in your gradle.build(project)

gradleVersion = '7.3.1'

in your gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip

Now you will be able to see the alert message when it's generated correctly with 1 variant text and the file path.

0

In my case all I did is just generate android bundle instead of APK and it worked fine for me. May be you can try this:- Genesrate

0

Observed this issue while changing multiple versions of grade.

Invalidated the caches from project settings and launched the android studio . The next build is successful and works fine.

-1

Rename the output path (yourapp/app/release to yourapp/app/relase_old) and rebuild your project.

1
-2

Just upgrade the project and it will solve the problem. A popup will show when you open the android studio.

1
  • 2
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 15, 2022 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.