How to fix 'Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: No outputs for the main artifact of variant:'

122,573

Solution 1

First clean your project by

Build -> Clean project

Then rebuild project

Build -> Rebuild project

Then run your project. I hope this will work.

if not then go to

File -> Invalidate Caches / Restart -> Invalidate and restart

The last option is you can sync Gradle again in case nothing worked

Solution 2

Your Gradle is out of sync. Go to: File -> Sync Project with Gradle Files. It should fix the problem.

enter image description here

Solution 3

This is because your gradle version in project build.gradle configuration is too old for a newer Android Studio version, like Android Studio 3.6.1,

1. you should change the gradle configuration into a newer one under: build.gradle(project)->buildscript->dependencies->classpath;

for example, you should change:

classpath 'com.android.tools.build:gradle:2.3.1'

into:

classpath 'com.android.tools.build:gradle:3.1.2'

2. after this, may be you should also change the configuration in gradle-wrapper.properties into a newer version, for example, change:

distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

into:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

3. after this, may be you should also add google() at:

build.gradle(project)->buildscript->repositories

and

build.gradle(project)->allprojects->repositories

Solution 4

I have the same issue with a Cordova Project after I updated Android Studio to 3.6.1

As a workaround (at least for the first installation of the app) I use installDebug Gradle Task from Gradle Tab View -> Tasks -> Install

enter image description here

Solution 5

I faced this problem today.

Select nothing from the installation option and click on the add icon button. Select Run Gradle task. enter image description here

Double click on the run Gradle task and there will be a pop-up option like the image. Change the first option to the app and the second option to install debug like the image.

Now finally you solved the problem

enter image description here

Share:
122,573

Related videos on Youtube

RAHUL UMAK
Author by

RAHUL UMAK

Android / iOS Developer

Updated on February 16, 2022

Comments

  • RAHUL UMAK
    RAHUL UMAK over 2 years

    I am trying to run a selected build variant but giving me following error in Run tab,

    Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: No outputs for the main artifact of variant: madhyapradesh-debug

    So kindly suggest the solution to it.

    • Boogier
      Boogier over 3 years
      I wonder why every Android Studio update is so painful. I prefer to keep existing version as long as possible because of this.
  • b3nk4n
    b3nk4n about 4 years
    this fix the problem I had with my LibGdx game. Thx!
  • Velda
    Velda almost 4 years
    I believe this will just run the application, but without updating it. At least if it's not an instant app.
  • Bruce
    Bruce over 3 years
    Update the classpath in the Project build works for me.Thank you!
  • CoolMind
    CoolMind over 3 years
    File > Invalidate Cashes / Restart... helped.
  • Eric
    Eric over 3 years
    After updating my gradle versions, I had to also Sync Project with Gradle Files to have it work. Thanks!!
  • eng.ahmed
    eng.ahmed over 3 years
    File->Invalidate Cashes /restart-> Invalidate and restart .. worked for me .. thanks :)
  • WhiteSpidy.
    WhiteSpidy. over 3 years
    These questions has already similar answers. Please don't copy other's answers.
  • Sreekanth Karumanaghat
    Sreekanth Karumanaghat over 3 years
    It is sad that such problems keep happening now and then.
  • Mahmoud Mabrok
    Mahmoud Mabrok over 3 years
    to which version
  • Naveed Ahmad
    Naveed Ahmad over 3 years
    File->Invalidate Cashes /restart-> Invalidate and restart worked
  • Gourango Sutradhar
    Gourango Sutradhar over 3 years
    You saved my day!
  • cslotty
    cslotty about 3 years
    I have done this before and it has helped, but this time it hasn't. I had to do the gradle sync.
  • firemaples
    firemaples about 3 years
    Pressing shift twice, searching sync gradle then pressing enter do the same stuff if you are lazy to move the cursor by mouse or touchpad.
  • CodeToLife
    CodeToLife about 3 years
    on windows Run tab->Edit config further as was said above then that plus mark appers on scroll. Also had picked up launch activity name in Launch option in advance.
  • Cooper Scott
    Cooper Scott about 3 years
    My build variant is greyed out but my device is plugged in and recognized by Android Studio
  • Andrey Aleev
    Andrey Aleev almost 3 years
    Only removing .gradle folder actually helped me. Invalidate Caches / Restart, Rebuilding project had no effect
  • Zaif Senpai
    Zaif Senpai almost 3 years
    My computer's power was disconnected due to an electricity issue while I was working on an android project. So I started facing this issue after that. Your answer solved my problem. Thanks!
  • Admin
    Admin over 2 years
    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.
  • Bhargav Thanki
    Bhargav Thanki over 2 years
    It worked. Thanks a lot
  • dotrinh
    dotrinh over 2 years
    File->Invalidate Cashes /restart-> Invalidate and restart worked well when I check very old commit in git to test
  • Mohsen Mirhoseini
    Mohsen Mirhoseini over 2 years
    Workaround 1 worked by deleting the app run config and resyncing the Gradle.
  • akshay
    akshay over 2 years
    File -> Invalidate Caches / Restart -> Invalidate and restart worked for me :)
  • Tanmay Agarwal
    Tanmay Agarwal about 2 years
    workaround 1 worked but plz can u tell me the reason behind that?? why does it works? and why it wasn't working before?
  • Bipin Gawand
    Bipin Gawand about 2 years
    Suberp....This should be high voted answer