Anael
Anael

Reputation: 470

Android studio - Generate signed APKs broke

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.

Upvotes: 55

Views: 23077

Answers (13)

Techie
Techie

Reputation: 1

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.

Upvotes: 0

Hussain Shabbir
Hussain Shabbir

Reputation: 15015

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

Upvotes: 0

c-an
c-an

Reputation: 4090

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.

Upvotes: 1

ÖMER TAŞCI
ÖMER TAŞCI

Reputation: 566

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

Upvotes: -1

Joseph .M 101
Joseph .M 101

Reputation: 221

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.

Upvotes: 3

Rohit Lalwani
Rohit Lalwani

Reputation: 579

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

Kindly check that folder for apk.

Upvotes: 7

Droid Chris
Droid Chris

Reputation: 3783

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

Upvotes: 46

Sreenath
Sreenath

Reputation: 1

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

Upvotes: -2

Sreehari K
Sreehari K

Reputation: 977

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

Upvotes: 3

Nikolaing
Nikolaing

Reputation: 21

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

Upvotes: 2

Mohammad Tabbara
Mohammad Tabbara

Reputation: 1467

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"

Upvotes: 3

Salman_Zach
Salman_Zach

Reputation: 891

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

Upvotes: 85

Anael
Anael

Reputation: 470

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.

Upvotes: 1

Related Questions