Error type 3 Error: Activity class {} does not exist
AndroidAndroid StudioAndroid ManifestAndroid Problem Overview
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:
Android Solutions
Solution 1 - Android
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 - Android
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 - Android
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 - Android
Solution 5 - Android
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.
Solution 6 - Android
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
Solution 7 - Android
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"
}
}
Solution 8 - Android
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.
Solution 9 - Android
AndroidManifest.xml
file.
Try changing the name of the Activity in your 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")
Solution 10 - Android
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
.
Solution 11 - Android
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.
Solution 12 - Android
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.
Solution 13 - Android
For me, the problem was that AndroidStudio
thought that the app was still on the device.
To fix it:
-
restart the
adb
daemon; in a terminal or command prompt, enter:adb kill-server adb start-server
-
try to launch your app.
-
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!
Solution 14 - Android
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.
Solution 15 - Android
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
Solution 16 - Android
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.
Solution 17 - Android
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"
Solution 18 - Android
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.
Solution 19 - Android
I use Android Studio 3.2 Beta 5, faced with the same issue
Go to
File -> Invalidate Caches / Restart...
Solved problem for me
Solution 20 - Android
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.
Solution 21 - Android
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".
Solution 22 - Android
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.
Solution 23 - Android
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 :)
Solution 24 - Android
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.
Solution 25 - Android
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.
Solution 26 - Android
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: https://stackoverflow.com/questions/19670607/error-type-3-activity-class-does-not-exist
Solution 27 - Android
Even I had the same problem but none of the above solutions worked for me. The problem was that, I had froze the particular app which I was trying to run via Titanium Backup due to which I got the above error. I tried both in Eclipse and Android Studio.
After the realization I just uninstalled the app and then ran it again.
Solution 28 - Android
I'd like to share the trick that helped in my case. I uninstalled the application from the device and nothing of clean/rebuild/Android Studio restart operations didn't help.
Since Android Studio thinks that the application is still installed on the device and doesn't deploy it, you can force the installation using the ADB:
adb install -r <your_application_from.apk>
where -r
means reinstall the app, keeping its data.
Solution 29 - Android
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.
- Delete your build folder it also includes the clean(so no need to clean it)
- Try to restart android studio if this doesn't work then invalidate the cache too.
- 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.
Solution 30 - Android
File -> Invalidate Caches / Restart
Solution 31 - Android
Refactor the activity launcher and change the class name.
Solution 32 - Android
Follow the below steps:
- Clean your Project
- Delete your build directory
- Restart your Android Studio
- Rebuild the project
Solution 33 - Android
I also faced the same problem somewhere in the past. Such problems actually occurs when we do some refactoring like - renaming, moving files within the project etc. Renaming and Moving files require changes in the gradle file so whenever you rename or move some file just clean the project:
> Build -> Clean Project
Cleaning the project just removes the .class files and recompiles the project. Basically, it forces a project rebuild.
Sometimes such types of errors did not cleaned on cleaning project then try to uninstall the app from the device (either it is emulator or physical one) and run the app again. Hope this will help you, it helps me 50% times.
Note:- Whenever you got any error just don't go to google, Clean the project if this not work do what you want to google.
Solution 34 - Android
I have LG Stylus and in my test phone, application isn't remove permanently. In Settings -> Application I found debug app (which I try install and debug by AS) with adnotation turn-off. When I remove app from my phone, error disappeard.
Solution 35 - Android
If your app is not installed at device (tested on Android 9) already:
- Build apk
- Move apk to device and install it
- Return to Android Studio and press Run to launch app
Solution 36 - Android
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.
Solution 37 - Android
Gradle -> Tasks -> Install -> Uninstall All.
Solution 38 - Android
I had been playing with Android Work Profiles by making use of the Shelter App - I had copied my own application into the work profile.
I had to remove my app from both the regular profile as well as the work profile, and then the app would launch properly. Somehow the existing package inside the work profile was getting in the way of the IDE deploy.
Solution 39 - Android
I resolve the problem by Edit Condifiguration -> Deploy-> Select default apk https://i.stack.imgur.com/8xuLG.png
Solution 40 - Android
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
Solution 41 - Android
Go to Build > Rebuild Project
Solution 42 - Android
I had a version of the app on the device that could not be uninstalled as it was corrupt somehow. I had to factory reset the device.
Solution 43 - Android
I took reference from @jayeffkay's comment:
> I had do delete gradle cache as described here https://stackoverflow.com/questions/22155938/android-studio-gets-package-name-wrong-when-running-apk/25602161#25602161
It works for me after I deleted the gradle cache files located in:
/your_proj_directory/.gradle/2.10
2.10 is the gradle version used in my case.
Solution 44 - Android
Disable instant run for Android Studio (tested on version 2.1.1)
Solution 45 - Android
I had Error type 3. I managed to fix it by adding the following code below in AndroidMainfest.xml.
<activity android:name=".GameActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Solution 46 - Android
I changed a NDK, and problem was solved.
Solution 47 - Android
If you're not careful and you're trying to disable something in your app manifest make sure you don't disable the app...
<application
android:allowBackup="false"
android:enabled="true"
...
I accidentally set enabled
to "false" instead of allowBackup
. Wasted 2 hours searching for a solution.
Solution 48 - Android
My solution is: close the "instant run" of android studio.
"instant run" can be found with the following steps: Preferences -> Build,Execution,Deployment -> Instant Run
and then uncheck the checkbox "Enable Instant Run to hot swap...."
Solution 49 - Android
If your app has only two word package name like[com.example] then all your class must be mentioned with full path in manifest like [com.example.SplashActivity] instead of relative path like[.SplashActivity] change this and delete all your build folder and re-run app.
Solution 50 - Android
Go to module settings -> Falvors -> Application id -> (Add your package name)
Solution 51 - Android
Just doing a clean build did the trick for me.
To do a clean build, do:
Build -> Clean Project
Then do a build or straight run on device.
Solution 52 - Android
For me, on Android Studio 3.1.2 on Ubuntu 16.04, I met the same issue. This happens when my colleague changed the package name, and it is okay on his machine. Neither clean project nor rebuild project work.
I use Sync project with gradle files button on the top pannel of Android Studio and everything works well.
Solution 53 - Android
Got to android/app/build.gradle
and search for
buildTypes {
....
}
You might have something like
buildTypes {
debug {
...
}
release {
...
}
customBuildType {
...
}
}
Chose the buildType
you want to start and then start the App the following
react-native run-android --variant=[buildType] --appIdSuffix '[buildType]'
So,
react-native run-android --variant=debug --appIdSuffix 'debug'
Solution 54 - Android
Remove the app in Android machine.
That works for me.
Solution 55 - Android
Keep package name same in manifest file and in build.gradle(Module:app).it resolved my problem.
Solution 56 - Android
I tried same app with different device it worked. Finally I noticed that the application is disabled:
- Go to setting/apps (on the phone)
- If it is disabled, remove it
Solution 57 - Android
This happens when the app has not been uninstalled properly.
Use the below plugin of Android Studio to uninstall the app from the device [in case you were unable to find your app inside the settings of the device]
ADBIdea: https://github.com/pbreault/adb-idea
ADBIdea adds the following ADB commands to Android Studio and Intellij:
- ADB Uninstall App
- ADB Kill App
- ADB Start App
- ADB Restart App
- ADB Clear App Data
- ADB Clear App Data and Restart
- ADB Revoke Permissions
- ADB Start App With Debugger
- ADB Restart App With Debugger
There are two basic ways to invoke a command:
Through the Tools->Android->ADB Idea menu By searching for "ADB" in "Find Actions"
- Mac OS X: Cmd + Shift + A
- Windows/Linux: Ctrl + Shift + A
Solution 58 - Android
I face this problem after rename my package...
so simplest one is go to File-> Invalidate caches/Restart ....
Solution 59 - Android
That might also happen if you have by mistake two launcher Activity in your AndroidManifest.xml
like this:
<activity android:name=".ActivityA">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".ActivityB">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Just leave the correct one LAUNCHER Activity
Solution 60 - Android
Besides the cases that the first upvoted comment provided, there is another case can cause this error: the output apk file cannot be replaced by Android Studio, you can manually delete it and build again, it should work.
If you did not change the output path, the default apk output path is {Your Project Path}/app/build/outputs/apk/debug/app-debug.apk
Solution 61 - Android
In my case, I don't know why, the smartphone was blocking my app. To solve it I went to Configuration --> Application , found my app and pressed "Unistall". I went to configuration becouse my application was not appearing on menu.
Solution 62 - Android
This worked on Android Studio version 4.0.1:
- Change my git branch to the master branch
- Return to my own branch
Solution 63 - Android
As others have noted, this problem can be caused by an attached device/emulator while uninstalling the app and AS connection still exists. On my end, I just delete all the build folders (under app and project dirs) in the project, and relaunch the application on the device/emulator.
Solution 64 - Android
Check if you are building hidden version. That’s intended behavior for hidden app.
If you want to build regular version, you need to change Build Variant in Android Studio Build > Select Build Variant, change it to regular.
Solution 65 - Android
If you create a new project from an existing project:
build.gradle
defaultConfig {
applicationId "xxxxxxxxx" //xxxxxxxxx should be "package name (com.demo.app) from AndroidMenifest.xml"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "3.0.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
then click sync in Android Studio
Solution 66 - Android
I solved it by simply deleting the app -> build
folder and then rebuilding the project. The build folder is automatically recreated after the project is built so there's no risk in deleting it.
Solution 67 - Android
This fix worked for me:
- Remove the installed debug APK from your phone
- In Android Studio, go to Build, choose Build APK(s)
- Put this generated APK on your phone and launch it
- Exit this app and try to debug your app again from Android Studio
Solution 68 - Android
This usually occurs when you uninstalling the App you are developing. Check whether you have activated the guest account, if so switch the account and uninstall the app, switch back to Admin user (You). and carry on!
Solution 69 - Android
In my case, I had defined defaultConfig
two times.
I don't know why but double check it in case of a mistake.
Solution 70 - Android
My package name was like "barisciftci.PatternApplier". So changing it to all lowercase solved my problem, so now it looks as "barisciftci.patternapplier".
Solution 71 - Android
I mistakenly added extra empty <application>
tag in AndroidMenifest.xml
which was causing this problem.
Solution 72 - Android
If you are getting this error while developing an instant app then go to Device Settings -> Apps and clear the instant app from device.
Solution 73 - Android
If you test your app on a smartphone, which has 24 hours secure app remove (like LG G6) you have to uninstall app manually in settings, because it is in bin for 24 hours after uninstalling, so Android Studio thinks that app is installed, but it is in app thrash on your smartphone.
Solution 74 - Android
Delete the virtual device and re-download it (tested on Android Studio 3.1.3, January 2019).
Solution 75 - Android
I read all the 'Run' Log and there I saw this line:
"Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space"
My problem was, no internal free space to install the app. So, I deleted some files and app get installed successfully.
Solution 76 - Android
In my case this was being caused by ndk abiFilters when compiling for arm. To fix it I had to add the following 'splits' section to app/build.gradle's android block:
splits {
abi {
enable true //enables the ABIs split mechanism
reset() //reset the list of ABIs to be included to an empty string
include "armeabi-v7a", "arm64-v8a", "armv7l"
universalApk true
}
}
Solution 77 - Android
Issue was caused by uninstalling the app while the device was still plugged in. What happens is the device disables the app rather than removing it.
- Go to your app list on your device and uninstall the app from there. You will see that it is currently marked as disabled. This is why you cannot run the app because Android Studio fails to install it as it thinks it already exists.
Solution 78 - Android
I'm solving simply (don't delete build folder):
- deleting all files *.apk in "\yourapp\app\build\intermediates\split-apk\debug\slices"
- running the app compare a popup message "Application Installation failed" "Do you want to uninstall the existing application?" click Ok
- rebuild the project
- run again the project
Solution 79 - Android
I got this error. What I tried to fix the error (didn't work) were:
- Clean Project
- Rebuild Project
- Restart Android Studio
Solution was simple , just uninstall the app on your Emulator/Phone and hit "Run" on Android Studio.
Solution 80 - Android
The problem occurred due to my Emulator. My emulator was running in SafeMood.
Restarting my Emulator without SafeMood worked. First it was started in SafeMood automatically and problem occurred. Then when I disable SafeMood and restart my Emulator it did the trick!
Solution 81 - Android
I face the same issue and I think the solution is very simple than what I think it was just go to your manifest and change the package name than copy the same package name into your application iD in the Gradle
defaultConfig { applicationId "your package name here" }
that's it, good luck
Solution 82 - Android
Check the following in android/app/src/main/AndroidManifest.xml
<application
android:name="[your_package_name].MainApplication"
...>
<activity
android:name="[your_package_name].MainActivity"
...>
Solution 83 - Android
I had the same error message when I switched to guest profile in my emulator. I switched back to owner profile and it worked.
Solution 84 - Android
Check Application id in the Gradle file. I had the same issue because I accidentally changes application id while refactoring views name.
Solution 85 - Android
For me, there was no space left on your device.
Solution 86 - Android
The file name of the SharedPreferences must be suffixed with the name of the current flavor to prevent the active compilation variant of a product from accessing the preferences of defined users for another active compilation with the same preference name.
Although each compilation package is different, it may be that when using flavorDimensions
, access to user preferences is being crossed and get the Error type 3 while launching MainActivity
app.getSharedPreferences("${BuildConfig.FLAVOR}_shared_pref_3", Context.MODE_PRIVATE)
GL
Solution 87 - Android
After all these solve suggestions i still had not solved my this problem. And then i remembered my phone has 2 ANDROID User Interface. One of them is using in casual, another is private things of yours. When i download my projects to phone, downloads both of them. I deleted my project in casual one but had not private one. Everything works fine when i delete the private one. So If you have 2 android ui, you should delete all of them and download again.
Solution 88 - Android
a simple hack is to rename your package : eg MainActivity to ApplicationMainActivity
Solution 89 - Android
Had the same error, with a much newer version of Android Studio (version 4.1) . A fresh install of Android Studio + a fresh "basic Activity" template would run into error type 3 for hours. I am on win 10 - my problem was how to kill the gradle
cache. A good answer above showed a screen snapshot from gradle
, but i didn't find it in Android Studio 4.1. Also the env vars for gradle
had not been set , and the commandline for gradle
didn't work. So .. here is how it worked finally. I went to C:\Users\myusername\ .gradle
. This has subdir
"caches". I deleted everything inside. Worked ! I did close Android Studio before, restarted and then it worked nicely. Ah forgot one thing- i run the device emulator (defauöt device), i.e. no physical device yet.
Solution 90 - Android
Happen to me when changing app name.. Uninstalled app, switched from debug to release version, installed release and then switched back to debug version and working.