59

Have anyone faced this issue with the new Android Studio 4.1. When I run the app to the simulator, everything works and builds. Later it also shows a message

enter image description here

In the run, the error message is

Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: Error loading build artifacts from: LOCATION/build/outputs/apk/act/debug/output-metadata.json
sadat
  • 4,004
  • 2
  • 29
  • 49

11 Answers11

49

I see this when switching branches from one that uses Android Gradle Plugin 4.0.1 and Gradle 6.1.1 to one that uses Android Gradle Plugin 4.1.1 and Gradle 6.5.

The workaround here is to manually run File > Sync Project with Gradle Files.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks a lot. It's working like charm after sync project with Gradle files. – sudharsan chandrasekaran Aug 01 '22 at 06:25
  • Hi CommonsWare, I tried all the work around provided here - https://stackoverflow.com/questions/56440572/how-to-fix-unable-to-determine-application-id-com-android-tools-idea-run-apkpr .... For me none of the solutions worked. I am still looking for solution. Also I have mentioned in one of the answer the strange behaviour observed with respect to issue. – Shadow Droid Jan 10 '23 at 05:46
20

I just figured out that, if you upgrade your gradle in one branch and change your branch to something which had the old gradle, you may face this issue.

I just updated the gradle and it fixed the issue.For me I change from

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

to

classpath 'com.android.tools.build:gradle:4.1.2'
sadat
  • 4,004
  • 2
  • 29
  • 49
6

Changing o updating your gradle version is not the real solution.

classpath 'com.android.tools.build:gradle:5.?.?'

if you change the value this is provoking a new project sync with the files of your project.

so the real solution is to synchronize the project with the Gradle files:

File > Sync Project with Gradle Files.

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
3

This fixed my issue. Go to

Run > Edit Configurations > Android App > app

On General tab change Launch option to

Default Activity

In my case it was selected

Nothing

mDonmez
  • 400
  • 4
  • 14
3

I met with this issue when I manually copied some files of one project into another(they were related to gradle).

So, In my case, the main issue was with the settings.gradle file. There is this line in the file:

rootProject.name = "Your App Name"

Make sure it is exactly similar to the home folder of your project.

R. Rohilla
  • 71
  • 8
  • 1
    Exactly, when I cloned the project onto another computer, I created a new folder name, and as you said, when I changed it to match the folder name, it worked. Thanks. – Reejesh PK May 23 '23 at 04:19
2

This is an issue of Gradle 4.1.1, Will work properly in Gradle 4.1.0, Please use :

classpath 'com.android.tools.build:gradle:4.1.0'
Mital Joshi
  • 1,132
  • 1
  • 11
  • 15
1

First Build->clean your project and then Build->Rebuild Project it will solve the problem

Yazdan Ilyas
  • 374
  • 4
  • 8
0

A possibility why This problem happens because of the run configuration. go to run configurations, within Before launch add Gradle-aware Make. It worked for me.

هيثم
  • 791
  • 8
  • 11
0

File/Invalidate Caches/Restart worked for me. Note: I already applied above mentioned solutions.

shaby
  • 1,301
  • 1
  • 15
  • 17
-1

I'm using RedMi android device, seems all the MI android phone should has this issue.

I tried all but doesn't work. The solution is turn off Turn on MIUI optimization in Developer options.

William Hu
  • 15,423
  • 11
  • 100
  • 121
-1

The problem occurred to me on beta version of the android studio. I fixed it by upgrading it to the latest version and upgrade the gradle to the next highest version.

This problem occurred to me when I tried to run jetpack compose samples from github.

Patrick Prakash
  • 500
  • 1
  • 7
  • 17