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

386,432

Solution 1

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.

Solution 2

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.

Solution 3

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.

Solution 4

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

Go to Gradle > Tasks > Install > uninstallAll

enter image description here

Solution 5

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.

Share:
386,432
Jacob
Author by

Jacob

Hi :) .. avoid this for your life quality ;) https://www.linkedin.com/in/kozlowskijakub

Updated on February 02, 2022

Comments

  • Jacob
    Jacob over 2 years

    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

  • Daniel Gilbert
    Daniel Gilbert over 9 years
    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.
  • Shivam Bhalla
    Shivam Bhalla about 9 years
    It works fine even without deleting the build directory.
  • jayeffkay
    jayeffkay almost 9 years
    I had do delete gradle cache as described here stackoverflow.com/a/25602161/630833
  • Juan Aguilar Guisado
    Juan Aguilar Guisado over 8 years
    The perfect (and unique) solution for me. I have a dynamic application id in my build.gradle (applicationId "com.example."+ CLIENT_ID)) in order to manage several clients' customization and everytime I changed the value of the variable I wasn't able to launch the app. Beer for you man!
  • zulkarnain shah
    zulkarnain shah over 8 years
    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.
  • blueether
    blueether about 8 years
    @shah, Android 1.5.1 -> facing the same issue. Above solution does not work
  • Heisenberg
    Heisenberg almost 8 years
    I had to delete the build directory coz a generated jar had my previous package name.
  • Yasitha Waduge
    Yasitha Waduge almost 8 years
    deleting gradle cache seems to be the work around after trying steps given above.
  • dcow
    dcow over 7 years
    @Siavash except it's not Correct™
  • mpaskov
    mpaskov over 7 years
    This does not seem lie an answer to me.
  • Siavash
    Siavash over 7 years
    How so @dcow? The accepted answer here didnt work for me, but this one did.
  • steven smith
    steven smith over 7 years
    Did all the above -- remove build directories, .gradle cache, invalidate/restart, turn off auto run, clean build. What finally worked was to re-sync gradle as in stackoverflow.com/questions/22155938/…
  • alexbchr
    alexbchr almost 7 years
    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.
  • smg
    smg almost 7 years
    (╯°□°)╯︵ ┻━┻ I had to clear the 'App Trash' on my device.
  • netcyrax
    netcyrax almost 7 years
    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.
  • Damn Vegetables
    Damn Vegetables over 6 years
    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...
  • JJF
    JJF over 6 years
    Bad as that was I still think it was better. Gradle is an abomination IMO.
  • StarWind0
    StarWind0 over 6 years
    I can't believe this worked. I had 2 accounts on my device and it was installed for the other user.
  • Long Dao
    Long Dao over 6 years
    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.
  • Damn Vegetables
    Damn Vegetables over 6 years
    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.
  • realtebo
    realtebo over 6 years
    Which one? adding a dot or a 3-level name?
  • realtebo
    realtebo over 6 years
    Please, explain how to add applicationId to buidl.gradle !
  • c.dunlap
    c.dunlap over 6 years
    I had this same issue after upgrading my device to Oreo. I'm still not sure what ultimately caused the issue but completely removing the app from the device and rebooting the device after performing all of the steps listed above (clean build and restart Android Studio) resolved the issue for me.
  • 最白目
    最白目 over 6 years
    @smg you should add this as an answer, also was the only thing that fixed it for me.
  • NOTiFY
    NOTiFY over 6 years
    This is the only thing that worked for me with Android Studio 3.1 Canary 7.
  • Nick
    Nick over 6 years
    I've also run into this many times. I follow the instructions above and often switch devices too. Sometimes when I have a physical device connected it still fails after doing the prescribed steps. So i'll run it on an emulator it which works fine then reconnect the other device. ¯_(ツ)_/¯
  • Opiatefuchs
    Opiatefuchs over 6 years
    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.
  • Salman500
    Salman500 about 6 years
    thnx man i was facing this problem on android oreo where application is not uninstalled success fully
  • Bugs Happen
    Bugs Happen about 6 years
    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
  • Mikhail Sharin
    Mikhail Sharin about 6 years
    Try to execute 'adb uninstall <package>' in terminal to completely remove app from device
  • N J
    N J about 6 years
    I have same problem. Nothing worked for me. Clean, restart, delete cache. The main issue was multi-user in handset. Removed app from other user and worked
  • luckylukein
    luckylukein about 6 years
    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.
  • Panduka DeSilva
    Panduka DeSilva about 6 years
    I came across the same issue and probably the answer should be updated with this solution as well
  • iamsujan
    iamsujan about 6 years
    my app was disabled
  • live-love
    live-love almost 6 years
    File - Sync Project with Gradle file was the only thing that worked for me
  • Roman T.
    Roman T. almost 6 years
    Hit "Refresh all gradle projects" button from the "Gradle" tab from the right (I am running Android Studio 3.1.2)
  • Rahul Rastogi
    Rahul Rastogi almost 6 years
    This error occurred to me when I configured multiple build types in my project.
  • Mike Keskinov
    Mike Keskinov almost 6 years
    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.
  • Paixols
    Paixols almost 6 years
    Xiaomi Mix 2 phone. When trying to uninstall an app I noticed it would uninstall properly, but it would also remain installed on the "Second Space" (Switch app) native to the phone. When removing the app from the second space -> Clean project in Android Studio & install again. It works!
  • Shainu Thomas
    Shainu Thomas almost 6 years
    cleaning and then building my project helped.
  • Ashutosh
    Ashutosh almost 6 years
    Yes, cleaning project and restarting Android Studio does the trick for me too
  • Victoria Klimova
    Victoria Klimova over 5 years
    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
  • Cililing
    Cililing over 5 years
    Worked for me. LG G6 has the same "feature" - I didn't find the way to disable it.
  • Silwester
    Silwester over 5 years
    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
  • Pritesh Vishwakarma
    Pritesh Vishwakarma over 5 years
    i have this [error type 3 Error: Activity class{} does not exist ] problem only in OnePlus A3003 device , rest in another device my app run and work perfectly. now how can i solve this issue ?
  • Jacqlyn
    Jacqlyn over 5 years
    @AjayCodes this can happen if the device has multiple user accounts on it. Going to the app menu in the settings, one can uninstall the app for all users.
  • PrasadW
    PrasadW over 5 years
    Sometimes it was caused due to errors while building with enabled Instant Run. After disabling that, it was able to run but sometimes still caused same issue. In that case I followed the approach of deleting the gradle cache.
  • Sreekanth Karumanaghat
    Sreekanth Karumanaghat over 5 years
    How to do this?
  • Raj kannan Iyyappan
    Raj kannan Iyyappan over 5 years
    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.
  • Shanison
    Shanison about 5 years
    This works for me. After running ./gradlew uninstallAll
  • Muhammed Yalçın Kuru
    Muhammed Yalçın Kuru about 5 years
    For Android Studio 3.2 . Go to File => Project Structure => App under Module section => select falvors from tab bar. Change or re-write even your package is correctly indicated.
  • Sakiboy
    Sakiboy about 5 years
    @Shanison , don’t forget that you can add aliases for all these different useful commands that we all forget. Just open you’re .bash_profile and add aliases for the commands you use all the time. This way you won’t have to type as much nor worry about memorizing all the different commands and spelling (me no gud at spellin).
  • Kirill Karmazin
    Kirill Karmazin about 5 years
    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)
  • Jason Butler
    Jason Butler about 5 years
    I had this issue and none of the above worked for me - however what did fix it was totally installing from the device. Not just by hitting uninstall - but going into phone settings, going to apps, and then 'Uninstall for ALL users'
  • Muhammad Ovi
    Muhammad Ovi almost 5 years
    This works! in my case adb uninstall com.demo where my app name was demo
  • Dipendra Sharma
    Dipendra Sharma almost 5 years
    com.demo will be your package name
  • Reeshabh Ranjan
    Reeshabh Ranjan almost 5 years
    adb uninstall <package_name> worked for me! Btw, here package name is the one that goes like com.android.example.appname.
  • Reeshabh Ranjan
    Reeshabh Ranjan almost 5 years
    @PriteshVishwakarma did you try to uninstall the package using adb?
  • Pritesh Vishwakarma
    Pritesh Vishwakarma almost 5 years
    @ReeshabhRanjan there was two user in one device. i solved this problem by uninstalling app manually.now i able to launch my app successfully.
  • Christian
    Christian almost 5 years
    I created an issue on the official tracker for this problem. Please star it to draw attention to the need of Google to fix this issue.
  • Chad Schultz
    Chad Schultz almost 5 years
    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.
  • praveenb
    praveenb almost 5 years
    Thanks to @NJ, on my Redmi device.. I created a Second space,. And then moved First Space. And then onwards, when i run apps from Android studio it shows App installed but it never appeared on screen. After a lot of struggle I find (NJ) comment. And then checked Second space, I see Android studio ran apps installed on Second space. I just deleted Second space. And restarted device. Solved the issue.
  • ykonda
    ykonda almost 5 years
    The only answer that worked! Android Studio 3.4.2, API Level 28
  • agmezr
    agmezr almost 5 years
    I had the same issue, I had a work profile on that device and for some reason the app was installed on both. After uninstall for both profiles I was able to install from Android Studio
  • iTurki
    iTurki almost 5 years
    I had the same issue. However, I couldn't uninstall the app following step #4. I had to do it using ADB adb uninstall [package_name]. Thanks @Nicks !
  • Peter
    Peter over 4 years
    OMG thank man, you saved my day. Same problem with fckn samsung
  • Bette Devine
    Bette Devine over 4 years
    deleting the build folder worked for me. Invalidates caches and restart didn't work.
  • Juan Monsalve
    Juan Monsalve over 4 years
    I have faced a few times this isssue and to me used to be enough the steps 6, 1 and 5: 1. Files -> invalidate caches/ restart 2. Clean Project 3. Run / debug
  • Michael Kern
    Michael Kern over 4 years
    You could also add application ID to module settings of application as an alternative
  • Tom Taylor
    Tom Taylor over 4 years
    I faced the same issue uninstall is just uninstalling for the current user. After uninstalling for all users it started working. Thanks a ton !
  • Shawn
    Shawn over 4 years
    This issue can also be caused by the Emulator being locked. Enter the pin to unlock the emulator and try running the app again.
  • dekaru
    dekaru over 4 years
    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.
  • LiuWenbin_NO.
    LiuWenbin_NO. about 4 years
    This works for me too. But why the issue happens and how uninstallAll would resolve? Thanks.
  • Big_Chair
    Big_Chair about 4 years
    What helped me was just go into the Play Store on the device and even though I deleted the app, it still showed the option "Delete" there. After pressing that button it all worked.
  • Hugo
    Hugo about 4 years
    This is the only thing that worked for me thank you!
  • anothercoder
    anothercoder about 4 years
    In my situation I had manually deleted my app from my physical android device and when I tried to rerun it from command line, I got the error. The error was a result of the app still being installed on the device globally, so I went to settings > apps > selected the app and deleted it. Once I did that, it was all good.
  • Thadeus Ajayi
    Thadeus Ajayi about 4 years
    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}
  • planetClaire
    planetClaire almost 4 years
    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).
  • Pooja
    Pooja almost 4 years
    This worked for me. Please explain how this would resolve the issue?
  • Saurabh Singh
    Saurabh Singh almost 4 years
    i had copy off app installed in "work profile" in samsung s9+, uninstalling all copies of the app worked out.
  • Manikandan Selvanathan
    Manikandan Selvanathan almost 4 years
    If you could not find the uninstallAll option in gradle side bar. Click run anything(gradle icon) then search for uninstallAll.
  • y.selimdogan
    y.selimdogan almost 4 years
    I uninstalled my app from the device homescrenn. After your answer, I checked the applications list and the app is still there and marked as like "not uninstalled from other users"... So deleted the app completely from my device solved the problem. Thanks.
  • Jenison Gracious
    Jenison Gracious over 3 years
    Mobile Settings > Apps > [Your App] > More > Uninstall App for All Users worked for me
  • zhqyvvn
    zhqyvvn over 3 years
    "Build -> Clean Project" and then "Build -> Rebuild Project" works for me.
  • MarkWalczak
    MarkWalczak over 3 years
    This worked for me. For multiple devices: adb -s <device ID> uninstall <package name>
  • Gev
    Gev over 3 years
    Thanks man, it worked for Android Studio 4.0.1
  • Achintha Isuru
    Achintha Isuru about 3 years
    For those who do not know where to access this panel is, it is in top right side of your screen.
  • Reece
    Reece almost 3 years
    This was also the case for me running Android 11 simulator on Apple Silicon (M1 chip) using arctic fox beta. Tried EVERYTHING on this forum. In the end noticed apk was being created in the app/build/output folder; so I used adb install -t path/to/apk.apk. After that subsequent attempts to run & debug from within android studio worked! Seems to happen every-time I upgrade AS / change machines.. *facepalm
  • rgisi
    rgisi almost 3 years
    and the same with an LG G6 after a day of developing... surely saved me a lot of time with this one!
  • Retebitall
    Retebitall over 2 years
    Worked for me after converting groovy to kts on 2020.1.1 canary 10
  • Rakesh
    Rakesh over 2 years
    Check whether the following values are same, package (usually line 2) in /android/app/src/main/AndroidManifest.xml applicationId (usually line 90) in defaultConfig section of /android/app/build.gradle Line 1 of /android/app/src/main/java/com/paysack/MainApplication.java Line 1 of /android/app/src/main/java/com/paysack/MainActivity.java
  • Constantine Kurbatov
    Constantine Kurbatov over 2 years
    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.
  • Dante Cervantes
    Dante Cervantes over 2 years
    thank you so much, i disabled the work profile, then enabled it again, and the app was under apps from work profile, uninstall it then ran flutter run and it works!
  • GUGAN RAJ
    GUGAN RAJ about 2 years
    100% Working i tried first 2 method thanks
  • Hoa Nguyen
    Hoa Nguyen almost 2 years
    This one works for me :D