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

2019-01-03 08:01发布

I have an INTELIJ(v12) android project successfully imported to AndroidStudio(v0.4.0). It works perfectly if I don't change anything in manifest. When I want to change the launcher activity and run, it outputs with the following 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

Anyone has faced this problem? Any ideas?

Run settings: enter image description here

30条回答
聊天终结者
2楼-- · 2019-01-03 08:32

None of the solutions above worked for me, I tried same app with different device it worked. Finally I noticed that the application is disabled.

  1. Go to setting/apps (on the phone)
  2. If it is disabled, remove it

That was the solution for my case

查看更多
We Are One
3楼-- · 2019-01-03 08:34

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

And everything worked fine!
I think the key is to restart your IDE.

Hope this helps you or anyone else!

Edit:
If above steps doesn't work for you, then deleting gradle cache seems 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 device.

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 Preferences option in the Android Studio top menu and look for Instant Run so you can uncheck the first checkbox on that screen.

enter image description here

Anyway that fixed it for me. Originally pointed out by user @yusufonder. I discovered this was the issue since gradle install still worked.

查看更多
女痞
4楼-- · 2019-01-03 08:34

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.

查看更多
\"骚年 ilove
5楼-- · 2019-01-03 08:34

If your app has only two word package name like[com.example] then all your class must be mentioned with full path in menifest like [com.example.SplashActivity] instead of relative path like[.SplashActivity] change this and delete all your build folder and re-run app . Hope it will help. Thanks

查看更多
神经病院院长
6楼-- · 2019-01-03 08:35

I faced this problem lately, and tried all suggestions above, and problem was not saved. Finally I changed a NDK, and problem was solved...

查看更多
够拽才男人
7楼-- · 2019-01-03 08:37

May be helpful for someone:--

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.
查看更多
登录 后发表回答