Android studio - Generate signed APKs broke
Asked Answered
M

13

55

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.

Magnanimous answered 1/10, 2021 at 15:11 Comment(2)
Have you solved this issue?Delacourt
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.Scoria
M
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.

Magnanimous answered 5/10, 2021 at 7:39 Comment(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.Bluejacket
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.Uthrop
@MarkSheekey Did you find any solution? I am still facing the same issueFiltration
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...Mayers
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.Neman
How is this the accepted answer? You still need to use APKs for various needs.Supporting
I get the same error with Android Studio Android Studio Dolphin | 2021.3.1 Patch 1 with only 1 of our apps, but for most of our apps, building an apk with Android Studio Dolphin is not an issue. No idea why it affected this one app and none of the others. But as others have stated, the apk for the affected app was actually built and works as expected.Stereotypy
G
84

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..

Gamble answered 1/2, 2022 at 12:44 Comment(2)
I confirm that all apk's are built.Mayers
true, it is under module/variant/module-variant.apkComment
S
46

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

Supporting answered 9/4, 2022 at 18:55 Comment(3)
work for me! so weirdDaffy
It's there but it generates broken apk file.Delacourt
@Delacourt 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.Supporting
M
6

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

Kindly check that folder for apk.

Monarchist answered 5/5, 2022 at 5:2 Comment(3)
Yes. It is generating. Thank youPettigrew
It's there but it generates broken apk file.Delacourt
than try to generate it again, if it fails than check your signin configsMonarchist
D
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"
Ducky answered 2/2, 2022 at 18:34 Comment(0)
F
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

Franky answered 7/3, 2022 at 20:1 Comment(0)
M
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.

Manta answered 9/6, 2022 at 14:41 Comment(0)
R
2

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

Reflate answered 19/2, 2022 at 11:30 Comment(0)
M
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.

Magnanimous answered 5/10, 2021 at 7:39 Comment(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.Bluejacket
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.Uthrop
@MarkSheekey Did you find any solution? I am still facing the same issueFiltration
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...Mayers
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.Neman
How is this the accepted answer? You still need to use APKs for various needs.Supporting
I get the same error with Android Studio Android Studio Dolphin | 2021.3.1 Patch 1 with only 1 of our apps, but for most of our apps, building an apk with Android Studio Dolphin is not an issue. No idea why it affected this one app and none of the others. But as others have stated, the apk for the affected app was actually built and works as expected.Stereotypy
D
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.

Delacourt answered 23/10, 2022 at 5:7 Comment(0)
F
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

Foxhole answered 6/11, 2022 at 21:42 Comment(0)
W
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.

Wherein answered 4/9, 2023 at 9:36 Comment(0)
C
-1

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

Cloyd answered 21/6, 2022 at 15:20 Comment(1)
incomplete ansawerGat
F
-2

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

Fidele answered 15/3, 2022 at 13:50 Comment(1)
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.Doglike

© 2022 - 2024 — McMap. All rights reserved.