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:
I faced a similar problem after refactoring.
This is what i did to resolve this issue:
Build
directoryAnd 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.
Sometimes when testing on a device, the app doesn't uninstall properly. To verify and fix this:
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.
I had the same issue and this is how I fixed it:
Go to Gradle > Tasks > Install > uninstallAll
This happens when you do the following
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
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.
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
.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With