Error type 3 Error: Activity class {} does not exist Error type 3 Error: Activity class {} does not exist android android

Error type 3 Error: Activity class {} does not exist


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.

Hope this helps you or anyone else!

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.


May be helpful for someone:--

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.


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.