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

AndroidAndroid Studio-3.0

Android Problem Overview


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.

Android Solutions


Solution 1 - Android

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

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

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

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

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

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

Solution 7 - Android

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

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

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

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

For me doing:

File -> Invalidate Caches / Restart

worked fine ^^

Solution 12 - Android

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

enter image description here

enter image description here

Solution 13 - Android

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

Project Structure - Suggestions - Update Gradle

Solution 15 - Android

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

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

Try running the following command on the Android Studio Terminal:

  • gradlew connectedAndroidTest

Solution 18 - Android

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

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

Solution 20 - Android

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

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

Solution 22 - Android

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.

Solution 23 - Android

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

Solution : Go to:

  1. File
  2. project structure (Ctrl + Alt + Shift + S)
  3. Suggestions
  4. Update Graddle

Then wait for downloading griddle to solve your problem.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRAHUL UMAKView Question on Stackoverflow
Solution 1 - AndroidMirza Ahmed BaigView Answer on Stackoverflow
Solution 2 - AndroidkadepeayView Answer on Stackoverflow
Solution 3 - AndroidapplixyView Answer on Stackoverflow
Solution 4 - AndroidLiviuView Answer on Stackoverflow
Solution 5 - AndroidShaonView Answer on Stackoverflow
Solution 6 - AndroidGuillaumeView Answer on Stackoverflow
Solution 7 - AndroidBraian CoronelView Answer on Stackoverflow
Solution 8 - AndroidShangeeth SivanView Answer on Stackoverflow
Solution 9 - AndroidSubarata TalukderView Answer on Stackoverflow
Solution 10 - AndroidNickUnuchekView Answer on Stackoverflow
Solution 11 - AndroidZ3R0View Answer on Stackoverflow
Solution 12 - AndroidjimView Answer on Stackoverflow
Solution 13 - AndroidshizhenView Answer on Stackoverflow
Solution 14 - AndroidTonka MatuskaView Answer on Stackoverflow
Solution 15 - AndroidGk Mohammad EmonView Answer on Stackoverflow
Solution 16 - AndroidampView Answer on Stackoverflow
Solution 17 - AndroidCherif DialloView Answer on Stackoverflow
Solution 18 - AndroidOmar AhmedView Answer on Stackoverflow
Solution 19 - AndroidChiView Answer on Stackoverflow
Solution 20 - AndroidRenRenView Answer on Stackoverflow
Solution 21 - AndroidYazdan IlyasView Answer on Stackoverflow
Solution 22 - AndroidManacyView Answer on Stackoverflow
Solution 23 - AndroidSalman KhãñView Answer on Stackoverflow