579

I have an IntelliJ Android project, that I successfully imported to Android Studio 0.4.0. It works perfectly if I don't change anything in manifest. However, when I want to change the launcher activity and run, it fails with this error:

Launching application: com.trackingeng/LandingActivity. DEVICE SHELL COMMAND: am start -D -n "com.trackingeng/LandingActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.trackingeng/LandingActivity } Error type 3 Error: Activity class {com.trackingeng/LandingActivity} does not exist. 

When I click Sync Project with Gradle files, it outputs:

Project Sync The project 'TrackingEng' is not a Gradle-based project 

Run settings: enter image description here

14
  • Where is your original AndroidManifest.xml file? Commented Jan 4, 2014 at 3:33
  • In the same place, under main folder in project. Commented Jan 4, 2014 at 9:30
  • I mean is this picture in the post is your original AndroidManifest.xml or not. Commented Jan 4, 2014 at 9:42
  • 8
    I have found a thread, hope could help. stackoverflow.com/questions/19670607/… Commented Jan 4, 2014 at 13:48
  • 6
    Though not effective in the OP's case, doing a gradle sync solved Error: Activity class {...} does not exist. for me. Commented May 8, 2016 at 3:00

98 Answers 98

855

I faced a similar problem after refactoring.
This is what i did to resolve this issue:

  1. Cleaned the Project
  2. Deleted the Build directory
  3. Restarted Android Studio
  4. Rebuild the Project
  5. Run
  6. Optionally (Go to the files menu on android, click on "Invalidate Caches / Restart..." uninstall the app on your phone and try again)

And everything worked fine!
I think the key is to restart your IDE.

Edit 1:
If the above steps don't work for you, then deleting Gradle cache seems to be a solution, as pointed out by @Yasitha.

Edit 2
As suggested by a couple of users in the comments below, sometimes the issue can be resolved by completely removing and reinstalling the app from your device.
Simply type adb uninstall <package> in terminal to completely remove app from the device.

Edit 3
As mentioned in Abhishek's Answer, one should also try deleting the app from your device in case multiple users are set up on your device.
Simply go to Mobile Settings > Apps > [Your App] > More > Uninstall App for All Users

Edit 4
As mentioned by Yassin Ajdi, executing the uninstallAll Gradle task can also fix the issue.
You can go to Gradle > Tasks > Install > uninstallAll to get the job done.

UPDATE for Android Studio 2.1 and up

When running Android Studio 2.1 and up you can also encounter this issue when you have the instant run option enabled in your preferences (is enabled by default).

To disable this option go to the Preferences option in the Android Studio top menu and look for Instant Run so you can uncheck the first checkbox on that screen.

Disable Instant Run in Android Studio 2.1+

Anyway that fixed it for me. Originally pointed out by user @yusufonder. I discovered this was the issue since gradle install still worked.

Sign up to request clarification or add additional context in comments.

37 Comments

I had do delete gradle cache as described here stackoverflow.com/a/25602161/630833
Though this is a late entry, but i am facing this problem only after updating Android Studio to 1.5 and the above solution doesn't work in my case.
Try to execute 'adb uninstall <package>' in terminal to completely remove app from device
On Android 7.0 when you uninstall the app on device (by dragging it to "Uninstall" label on the device main screen), the app in fact just "disabled". You need to go to Settings/Apps and manually remove the app from there (alternatively use ADB command). I bounce into it couple of times, but after a few mouths I get forgetting about this Android 7.0 so called feature.
adb uninstall <package_name> worked for me! Btw, here package name is the one that goes like com.android.example.appname.
|
386

Sometimes when testing on a device, the app doesn't uninstall properly. To verify and fix this:

  1. Go to Settings.
  2. Go to Apps.
  3. Select your app. (here, you can verify that your app is not uninstalled properly).
  4. Open the overflow menu on the top right and select Uninstall for all users.
  5. Done. Try to install then launch your app again.

9 Comments

Using Android O developer preview 3, I could not perform the Uninstall for all users action, as it told me that the app did not exist in apps list. Running adb uninstall {packageName} solved the problem.
For emulator, Ankit's answer did not work. I had deleted my app from the launcher, but it remained on the system, which caused the problem. I had to use this method to uninstall it completely.
thnx man i was facing this problem on android oreo where application is not uninstalled success fully
This was exactly my problem, app was not installed for this user. Just uninstalled it by the procedure mentioned above and it started to work
my app was disabled
|
128

I would face this problem when uninstalling the app via the device (i.e. dragging the app to the "Uninstall" option). But here is the proper way to uninstall:

Use the ./gradlew uninstallAll command. This will prevent the Error: Activity class {HomeActivity} does not exist. error.

Update:

If you’re lazy you can use the abbreviation for this task: ./gradlew uA.

Or define aliases for common gradle tasks in your .bash_profile, doing so will save time, typing, and you won’t have to remember every command nor worry about typos. I suggest doing this.

9 Comments

This is the only thing that worked for me with Android Studio 3.1 Canary 7.
great answer. Some devices seems to have a problem with uninstall. For me, it is Xiaomi Mi Mix 2 with EU Build. I guess it is a error in Build version of device.
This works for me. After running ./gradlew uninstallAll
This one did the trick after I uninstalled the app on the device. Also, you can make a small shortcut to uninstall your app. Just create an empty .txt file and paste the following line: C:\Users\K\AppData\Local\Android\sdk\platform-tools\adb.exe uninstall com.myapp.packagename. Then rename this .txt file to .bat and you can run it every time you want to uninstall your app (on Windows)
Worked for me after converting groovy to kts on 2020.1.1 canary 10
|
79

I had the same issue and this is how I fixed it:

Go to Gradle > Tasks > Install > uninstallAll

enter image description here

4 Comments

This works for me too. But why the issue happens and how uninstallAll would resolve? Thanks.
This worked for me. Please explain how this would resolve the issue?
If you could not find the uninstallAll option in gradle side bar. Click run anything(gradle icon) then search for uninstallAll.
For those who do not know where to access this panel is, it is in top right side of your screen.
76

This happens when you do the following

  • connect your device/emulator
  • run the app from Android Studio (AS)
  • use/test the app and uninstall it from the device while it is still connected to your computer
  • try to run the app again from AS

AS thinks you still have the app in your device.

tl;dr - To resolve this, you can simply disconnect your device after uninstalling the app and reconnect it.

4 Comments

Though don't let yourself get confused if the app doesn't show up in the Launcher, just check settings/Apps -> "All" if the app is listed. That was the case with my application, and after removing it, everything worked fine again.
If it does not appear in the Launcher as @DanielGilbert said, you can easily uninstall with "adb uninstall package.name". This worked for me too.
This worked for me too. I was running a sample project, which has two versions. I installed the first version, and then uninstalled it to install the second version. I have wasted a lot of time to fix the error. This is not the first time that Android development had this kind of weird, unsolvable issues...
My case. Disconnect and connect device - this worked for me! The app was not on the device, but AS didn't install it thinking that the app is still in my device
64

The App is already installed for Another user. Please try to uninstall the same app for all the user. Then try.

Or you can try after running adb command.

adb uninstall PACKAGE_NAME 

where PACKAGE_NAME is the full name such as com.example.myapp

3 Comments

This works! in my case adb uninstall com.demo where my app name was demo
com.demo will be your package name
The only answer that worked! Android Studio 3.4.2, API Level 28
30

I had the same error after renaming/refactoring. What I did was add the applicationId property attribute to my build.gradle file, and set its value to the application package.

In build.gradle:

android { defaultConfig { applicationId "com.example.myapp" } } 

2 Comments

Please, explain how to add applicationId to buidl.gradle !
You could also add application ID to module settings of application as an alternative
25

In my case i uninstalled application from phone it after that the problem began but, the below command worked for me.

Execute below command in terminal/cmd

adb uninstall <package_name> 

package_name something like com.example.applicationname Then, try to reinstall the application. It should work.

3 Comments

This worked for me since I had previously installed the apk via adb, but somehow uninstalling it via the phone's app manager left some app traces.
This worked for me. For multiple devices: adb -s <device ID> uninstall <package name>
To get the list of devices use the following command: $/Users/<user>/Library/Android/sdk/platform-tools/adb devices to get list of devices (something like 'VQM0218126001101' or 'emulator-5555' ) and then: $/Users/<user>/Library/Android/sdk/platform-tools/adb -s <device_ID> uninstall "com.<xxxxx>.<xxxx>" And wait for Success result string.
24

This happened to me using react-native run-android because my package name did not match my app ID. Just add --appId YOUR_APP_ID.

3 Comments

This happened to be my problem, the package name was renamed, but the folder structure didn't follow the pattern. PackageName com.{biz_name}.{app.name} Folder structure was just com.{app.name}
This became an issue for me after upgrading react native from 0.61.5 to 0.62.2, my app id has never matched my package name, but after the upgrade I need to add --appId YOUR_APP_ID (note it's --appId not app-id).
After spending hours trying all the different ways to uninstall etc. from the other answers, this simply fixed the problem. I also ran into it upgrading to RN 0.62.x. What could have changed in the config files to make this necessary?
21

Try changing the name of the Activity in your AndroidManifest.xml file.

Right now it says:

<activity android:name="LandingActivity" > 

Try either adding a period to the beginning of the Activity's name:

<activity android:name=".LandingActivity" > 

Or adding the package name to the beginning of the Activity's name:

<activity android:name="com.trackingeng.LandingActivity" > 

It also may be a problem that your package name has only two components separated by periods (your package name is "com.trackingeng"; a more standard package name would be "com.trackingeng.app")

3 Comments

@Siavash except it's not Correct™
How so @dcow? The accepted answer here didnt work for me, but this one did.
Which one? adding a dot or a 3-level name?
20

Follow Steps Below Go to Mobile setting > Apps > Your App > More > Hit Uninstall app for all users.

Reason : Because you are having multiple users in your phone and you had uninstalled that app for only one.

Comments

16

I think another reason that issue happen is that it is not fully deleted for all users on the device.

Go to Settings -> Apps - > Your Apps -> Click to the 3 dots on the top right -> Uninstall for all users

It works for me. It happen especially you change the icons of the app or messing around with the AndroidManifest.xml file.

2 Comments

I can't believe this worked. I had 2 accounts on my device and it was installed for the other user.
yeah it is a bit annoying but it normally happen when the app is under development cause you might want to change loading icons and stuff etc.
14

When I got this problem I always try this solution and it works.

Instant Run disable Build -> Clean Project File -> Invalidate Caches / Restart 

But I found an exception this once. This solution doesn't work for me. Then I find out the problem is Emulator cash. I just do Wipe data and Cold boot now and the problem is solved.

enter image description here

Comments

13

For me, the problem was that AndroidStudio thought that the app was still on the device.

To fix it:

  1. restart the adb daemon; in a terminal or command prompt, enter:

    adb kill-server adb start-server 
  2. try to launch your app.

  3. if it still doesn't work, check out this answer.

make sure the platform-tools of the Android SDK is added to your system path variables!

Comments

12

Try this from terminal

gradlew uninstallAll 

This will uninstall all the debug, release, apks of all the versions of your app. And re-install the application

Comments

11

Below command worked for me. Sometime partial uninstallation of the app also causes this.

Execute below command in terminal/cmd

adb uninstall <package_name> 

Then, try to reinstall the application. It should work.

Comments

9

On Android 6, when I uninstalled the app it actually went to disabled instead of being removed from device.

Settings > Apps > click on your app and uninstall

1 Comment

That works, but some more points. If you delete it via adb it doesn't guarantee that problem is solved, event if you don't see this package via adb pm. You have to do it with hands, find it in Settings->App and choose Delete for all users. After that you can install it again
8

Some times application install on Guest user on your mobile, So try to switch Guest and uninstall the application.

In addition, try to execute the following command to uninstall application adb uninstall package "Your package Name"

Comments

8

File -> Invalidate Caches / Restart

Comments

8

Sometimes this happens once you rename the project's root directory, just delete the .idea folder of your project and reopen it with Android Studio.

Comments

7

Be warned that if you have multiple Profiles set on the device, your app might already exist in one of the other Profiles.

Uninstalling the app from all the Profiles resolved the issue for me.

Comments

7

I use Android Studio 3.2 Beta 5, faced with the same issue

Go to

File -> Invalidate Caches / Restart... 

Solved problem for me

Comments

7

In my case, it was because the app I was trying to launch was installed for a different user on the device. Go to Settings -> Apps (All apps) and and select the app. Click on the overflow menu and select "Uninstall for all users".

3 Comments

This happened to e too and I had to go to Settings> Apps and Notifications> App info. Had to "Uninstall for all users" and install again.
I came across the same issue and probably the answer should be updated with this solution as well
This error occurred to me when I configured multiple build types in my project.
6

For me it was a very specific problem, I've got a Lg g5 to test my application on, and to reset my apps data I uninstalled it on the phone, but the phone has a "nice" feature to don't uninstall apps immediatly so you might can reinstall them within one day. So the app was installed but not usable(disabled) after removing the app from the phone completely it worked.

1 Comment

Worked for me. LG G6 has the same "feature" - I didn't find the way to disable it.
6

Just in case anyone runs into my issue and has no luck with the other solutions... I was trying to start an activity through adb for FireTV while debugging Amazon launcher integration. However, my project had 60 different build variants (multi-platform, multi-app project) and the ApplicationId didn't match any classpath since the runtime package (and classpaths) were different from the applicationId.

I was trying to run adb shell am start -n com.myappid.example.packageone.packagetwo/com.myappid.example.packageone.packagetwo.MySplashActivity

(Of course I had tried many combinations with com.runtimepath.example since I had the added challenge of a different applicationId in my build.gradle and another at runtime)

What finally helped was this post https://stackoverflow.com/a/36255727/5970652

Which revealed a different format! com.myappid.example/com.runtimepath.example.packageone.packagetwo.MySplashActivity

So if you have a different runtime classpath try specifying with the build.gradle applicationId before the slash and the runtime classpath afterwards.

You can also get these values from BuildConfig.APPLICATION_ID and this.getLocalClassName() respectively if you want to log them in logcat.

1 Comment

This was exactly my problem! I was frustrated for a while, but once I put the app package name before the slash, and the fully qualified package/class name after the slash it worked.
6

In my case there was next reason:

I have 2 users: me and Guest. and app was installed on both of them but deleted only at first.

when I switched to Guest screen and delete app from there, app installed ok.

hope this will help someone :)

Comments

6

If you have uninstalled the application manually from the device and you have multi user set up, this error could happen. The application needs to be uninstalled from all the users in the device.

3 Comments

How to do this?
If you have multiple users, it can be found in notification drawer in the home screen (It'll be there along with the settings icon). Otherwise, go to the settings page and go to System->Multiple Users and click that user. After logging into the other user, the app can be uninstalled.
i had copy off app installed in "work profile" in samsung s9+, uninstalling all copies of the app worked out.
6

In my case, I actually change the package name, and it started causing this issue.

I have tried many trick but here I am describing what actually worked for me.

  1. Delete your build folder it also includes the clean(so no need to clean it)
  2. Try to restart android studio if this doesn't work then invalidate the cache too.
  3. if it still give you error then try to wipe out the data of your emulator, hopefully this will resolve the issue,

Make sure your activity name is correct also make sure the package name is correct in manifest file.

Comments

6

I have a Samsung Galaxy. Searching in the settings above didn't work because it didn't show up at all in my Apps settings.

I found the application on my phone by typing the name of the app in the search field. I realized it was in the "Work"(using Mobile@Work) profile and removed it. You can find the settings for the profile by going to Settings->Work profile->Apps

I hope this helps somebody who may not find it the same way that many of the other answers stated it could be found in the settings.

2 Comments

OMG thank man, you saved my day. Same problem with fckn samsung
and the same with an LG G6 after a day of developing... surely saved me a lot of time with this one!
6

Faced this problem in android studio 3.5.1 Took me a day to solve this problem,Tried everything including cleaning cache,restart and renaming package name as well. So if any of above did't work than try this.

Just go to gradle > Tasks > Install > UninstallAll

Here is the link: Error type 3: Activity Class {...} does not exist

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.