Error type 3 Error: Activity class {} does not exist
Solution 1
I faced a similar problem after refactoring.
This is what i did to resolve this issue:
- Cleaned the Project
- Deleted the
Build
directory - Restarted Android Studio
- Rebuild the Project
- Run
- 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.
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:
- Go to Settings.
- Go to Apps.
- Select your app. (here, you can verify that your app is not uninstalled properly).
- Open the overflow menu on the top right and select Uninstall for all users.
- 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
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.
Jacob
Hi :) .. avoid this for your life quality ;) https://www.linkedin.com/in/kozlowskijakub
Updated on February 02, 2022Comments
-
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:
-
Daniel Gilbert over 9 yearsThough 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 about 9 yearsIt works fine even without deleting the build directory.
-
jayeffkay almost 9 yearsI had do delete gradle cache as described here stackoverflow.com/a/25602161/630833
-
Juan Aguilar Guisado over 8 yearsThe 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 over 8 yearsThough 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 about 8 years@shah, Android 1.5.1 -> facing the same issue. Above solution does not work
-
Heisenberg almost 8 yearsI had to delete the build directory coz a generated jar had my previous package name.
-
Yasitha Waduge almost 8 yearsdeleting gradle cache seems to be the work around after trying steps given above.
-
dcow over 7 years@Siavash except it's not Correct™
-
mpaskov over 7 yearsThis does not seem lie an answer to me.
-
Siavash over 7 yearsHow so @dcow? The accepted answer here didnt work for me, but this one did.
-
steven smith over 7 yearsDid 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 almost 7 yearsUsing 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 almost 7 years(╯°□°)╯︵ ┻━┻ I had to clear the 'App Trash' on my device.
-
netcyrax almost 7 yearsIf 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 over 6 yearsThis 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 over 6 yearsBad as that was I still think it was better. Gradle is an abomination IMO.
-
StarWind0 over 6 yearsI can't believe this worked. I had 2 accounts on my device and it was installed for the other user.
-
Long Dao over 6 yearsyeah 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 over 6 yearsFor 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 over 6 yearsWhich one? adding a dot or a 3-level name?
-
realtebo over 6 yearsPlease, explain how to add applicationId to buidl.gradle !
-
c.dunlap over 6 yearsI 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 over 6 yearsThis is the only thing that worked for me with Android Studio 3.1 Canary 7.
-
Nick over 6 yearsI'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 over 6 yearsgreat 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 about 6 yearsthnx man i was facing this problem on android oreo where application is not uninstalled success fully
-
Bugs Happen about 6 yearsThis 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 about 6 yearsTry to execute 'adb uninstall <package>' in terminal to completely remove app from device
-
N J about 6 yearsI 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 about 6 yearsThis 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 about 6 yearsI came across the same issue and probably the answer should be updated with this solution as well
-
iamsujan about 6 yearsmy app was disabled
-
live-love almost 6 yearsFile - Sync Project with Gradle file was the only thing that worked for me
-
Roman T. almost 6 yearsHit "Refresh all gradle projects" button from the "Gradle" tab from the right (I am running Android Studio 3.1.2)
-
Rahul Rastogi almost 6 yearsThis error occurred to me when I configured multiple build types in my project.
-
Mike Keskinov almost 6 yearsOn 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 almost 6 yearsXiaomi 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 almost 6 yearscleaning and then building my project helped.
-
Ashutosh almost 6 yearsYes, cleaning project and restarting Android Studio does the trick for me too
-
Victoria Klimova over 5 yearsMy 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 over 5 yearsWorked for me. LG G6 has the same "feature" - I didn't find the way to disable it.
-
Silwester over 5 yearsThat 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 over 5 yearsi 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 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 over 5 yearsSometimes 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 over 5 yearsHow to do this?
-
Raj kannan Iyyappan over 5 yearsIf 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 about 5 yearsThis works for me. After running ./gradlew uninstallAll
-
Muhammed Yalçın Kuru about 5 yearsFor 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 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 about 5 yearsThis 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 about 5 yearsI 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 almost 5 yearsThis works! in my case
adb uninstall com.demo
where my app name wasdemo
-
Dipendra Sharma almost 5 yearscom.demo will be your package name
-
Reeshabh Ranjan almost 5 years
adb uninstall <package_name>
worked for me! Btw, here package name is the one that goes likecom.android.example.appname
. -
Reeshabh Ranjan almost 5 years@PriteshVishwakarma did you try to uninstall the package using adb?
-
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 almost 5 yearsI 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 almost 5 yearsThis 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 almost 5 yearsThanks 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 almost 5 yearsThe only answer that worked! Android Studio 3.4.2, API Level 28
-
agmezr almost 5 yearsI 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 almost 5 yearsI 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 over 4 yearsOMG thank man, you saved my day. Same problem with fckn samsung
-
Bette Devine over 4 yearsdeleting the build folder worked for me. Invalidates caches and restart didn't work.
-
Juan Monsalve over 4 yearsI 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 over 4 yearsYou could also add application ID to module settings of application as an alternative
-
Tom Taylor over 4 yearsI faced the same issue uninstall is just uninstalling for the current user. After uninstalling for all users it started working. Thanks a ton !
-
Shawn over 4 yearsThis issue can also be caused by the Emulator being locked. Enter the pin to unlock the emulator and try running the app again.
-
dekaru over 4 yearsThis 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. about 4 yearsThis works for me too. But why the issue happens and how
uninstallAll
would resolve? Thanks. -
Big_Chair about 4 yearsWhat 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 about 4 yearsThis is the only thing that worked for me thank you!
-
anothercoder about 4 yearsIn 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 about 4 yearsThis 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 almost 4 yearsThis 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 almost 4 yearsThis worked for me. Please explain how this would resolve the issue?
-
Saurabh Singh almost 4 yearsi had copy off app installed in "work profile" in samsung s9+, uninstalling all copies of the app worked out.
-
Manikandan Selvanathan almost 4 yearsIf you could not find the uninstallAll option in gradle side bar. Click run anything(gradle icon) then search for uninstallAll.
-
y.selimdogan almost 4 yearsI 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 over 3 yearsMobile Settings > Apps > [Your App] > More > Uninstall App for All Users worked for me
-
zhqyvvn over 3 years"Build -> Clean Project" and then "Build -> Rebuild Project" works for me.
-
MarkWalczak over 3 yearsThis worked for me. For multiple devices: adb -s <device ID> uninstall <package name>
-
Gev over 3 yearsThanks man, it worked for Android Studio 4.0.1
-
Achintha Isuru about 3 yearsFor those who do not know where to access this panel is, it is in top right side of your screen.
-
Reece almost 3 yearsThis 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 almost 3 yearsand the same with an LG G6 after a day of developing... surely saved me a lot of time with this one!
-
Retebitall over 2 yearsWorked for me after converting groovy to kts on 2020.1.1 canary 10
-
Rakesh over 2 yearsCheck 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 over 2 yearsTo 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 forSuccess
result string. -
Dante Cervantes over 2 yearsthank 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 about 2 years100% Working i tried first 2 method thanks
-
Hoa Nguyen almost 2 yearsThis one works for me :D