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

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.



Solution 1:[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:[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:[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:[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:[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

Solution 6:[6]

For me the solution was apparently to update the Gradle plugin...

Solution 7:[7]

Workaround 1

Create a new configuration for Run with the same parameters as the default config app. This work for me.

  1. Run
  2. Edit Configuration
  3. Add New Configuration (NOT COPY) -> Android App
  4. Rename
  5. Choose app Module
  6. Apply

Workaround 2

  1. Use the task for install in Gradle Tab View -> Tasks -> Install
  2. Run the app.

Workaround 3

  1. Delete .gradle folder
  2. Invalidate Caches / Restart ...
  3. Run the app

Solution 8:[8]

Sometimes a gradle sync and run will do the job. I was facing this after gradle plugin update too. Gradle sync might not have happened sometimes.

Solution 9:[9]

Do follow the three steps:

  1. Clean project: Build(menu) >> Clean Project
  2. Sync project: File(Menu) >> Sync Project with Gradle Files
  3. Rebuild project: Build(menu) >> Rebuild Project

Now run your app and enjoy.

Solution 10:[10]

I faced this problem today.

Select "Default APK" from the installation option and click on the add icon button. Select "Gradle-aware Make"->"OK" enter image description here

Solution 11:[11]

For me doing:

File -> Invalidate Caches / Restart

worked fine ^^

Solution 12:[12]

Set Deploy to NOTHING worked for me. (kudos to above nvatvm above)

enter image description here

enter image description here

Solution 13:[13]

Ensure that your have set applicationId "com.example.myapp" in your build.gradle

android {
    ...
    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    ...
}

And from app -> Edit Configurations, ensure that you have selected "Default Activity"

Solution 14:[14]

Project Structure - Suggestions - Update Gradle

Solution 15:[15]

First of all Clean Project and Rebuild Project. If it doesn't work then the Easy, Hardcore, Fast approach which works for me was just deleting the two following folder named .gradle and .idea after closing the IDE and restart it -

enter image description here

Solution 16:[16]

My solution was to upgrade Android Studio from "Artic Fox | 2021.3.1 Canary 12" to "Artic Fox | 2021.3.1 Canary 13"

Solution 17:[17]

Try running the following command on the Android Studio Terminal:

  • gradlew connectedAndroidTest

Solution 18:[18]

You need to update the Gradle version: go to File -> Project structure, then update the Android Gradle Plugin version, and Gradle Version to the latest stable versions(now 7.0.2 & 7.2 respectively)

Solution 19:[19]

View Gradle Table => right click the application => click "Reload Gradle Project"

Solution 20:[20]

Check if you have Build Variant selected: Go to Menu > Build > Select Build Variant

Select a build variant that ends with Debug for the Release Variants you need the signing certificate configured correctly.

Solution 21:[21]

First clean your project and then rebuild the project it will solve the problem

Solution 22:[22]

The answer by @applixy worked for me. 1.Just note to update the classpath to the latest version in project->build.gradle to

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

2.And in the gradle->wrapper.proprties just apply sync with gradle upon distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip

3.My project already had the google() method on allprojects{}. So build your project and run you are good to go.