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.0Android 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.
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
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.
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
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.
- Run
- Edit Configuration
- Add New Configuration (NOT COPY) -> Android App
- Rename
- Choose app Module
- Apply
Workaround 2
- Use the task for install in
Gradle Tab View -> Tasks -> Install
Run
the app.
Workaround 3
- Delete .gradle folder
- Invalidate Caches / Restart ...
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:
- Clean project: Build(menu) >> Clean Project
- Sync project: File(Menu) >> Sync Project with Gradle Files
- 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"
Solution 11 - Android
For me doing:
File -> Invalidate Caches / Restart
worked fine ^^
Solution 12 - Android
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 -
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:
- File
- project structure (Ctrl + Alt + Shift + S)
- Suggestions
- Update Graddle
Then wait for downloading griddle to solve your problem.