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
https://i.stack.imgur.com/mbMmP.jpg
AndroidManifest.xml
or not.
Error: Activity class {...} does not exist.
for me.
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.
https://i.stack.imgur.com/sYyyt.png
Anyway that fixed it for me. Originally pointed out by user @yusufonder. I discovered this was the issue since gradle install still worked.
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.
adb uninstall {packageName}
solved the problem.
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.
.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)
I had the same issue and this is how I fixed it:
Go to Gradle > Tasks > Install > uninstallAll
https://i.stack.imgur.com/o6kmE.png
uninstallAll
would resolve? Thanks.
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.
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
adb uninstall com.demo
where my app name was demo
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"
}
}
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.
$/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.
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")
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
.
PackageName com.{biz_name}.{app.name} Folder structure was just com.{app.name}
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.
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.
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!
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.
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.
https://i.stack.imgur.com/X4AUb.png
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
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"
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.
I use Android Studio 3.2 Beta 5, faced with the same issue
Go to
File -> Invalidate Caches / Restart...
Solved problem for me
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.
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.
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 :)
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.
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.
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
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".
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.
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.
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.
File -> Invalidate Caches / Restart
Success story sharing
adb uninstall <package_name>
worked for me! Btw, here package name is the one that goes likecom.android.example.appname
.