Activity class does not exist

匿名 (未验证) 提交于 2019-12-03 01:33:01

问题:

Aaaargh! I don't know what's going on, but suddenly I can't launch my app. I'm using IntelliJ and I keep getting this error. I thought maybe there was a typo somewhere in the manifest, but there doesn't seem to be. Heres' the error:

Launching application: com.foo.app/com.foo.app.main. DEVICE SHELL COMMAND: am start -n "com.foo.app/com.foo.app.main" Starting: Intent { cmp=com.foo.app/.main} Error type 3 Error: Activity class {com.foo.app/com.foo.app.main} does not exist. 

And here's my Manifest:

And the strange thing is that ADB shows me that the ActivityManager is starting the intent just fine...

回答1:

The problem is in the build / run configuration of your project. You have to check the "Deploy application" checkbox in the Run/Debug Configuration screen, under the General tab.

This solved my problem.



回答2:

Check if you don't have another application with the same package id installed on device: https://stackoverflow.com/a/22524188/540639



回答3:

I had a very similar error. In my case the application was not completely removed from the Android phone. I simply removed it using ADB, e.g. adb unsinstall com.your_app_name



回答4:

after checking all other things that people stated in their post, check in the IDEA: Run -> Edit Configurations -> Android Application -> Launch the activity that you want to start on launch of your application should be there...



回答5:

I had a problem with identical symptoms and following solved it in my case.

  1. If you're not already, use LogCat window to get more precise information about the exception than console offers.

  2. If you haven't already, check through your layout XML files in case you have a custom object and you're using the wrong path for a resource.

  3. If you haven't already, or you have to address the above, try cleaning your project and then building again.



回答6:

I have tried every suggestion i found, but couldnt solve the issue. After that i figured it out myself: The problem in my case was that i renamed the package. To make sure you dont get the error above, add the

  defaultConfig {      applicationId "com.yourpackage.yourapplication"   } 

to your build.gradle file. Hope that helps.



回答7:

Rebuild the application and run it.

This solved my problem.



回答8:

I found an extra tag in my manifest, I don't know how it got there but removing it fixed my issue.



回答9:

I get this all the time in intellij.

It looks like you are missing the line that states what your default package is e.g. Com.foo. Something is wrong with your manifest there...try creating a new blank test project and compare what you are missing because that looks like it is too short.



回答10:

Also double check the package and activity name. I got a similar error caused by a missing dot in front of the activity name (e.g. "package.Activity" instead of ".package.Activity" ). IntelliJ didn't mark it as wrong so it was easily overlooked.



回答11:

Similar to Joff's answer. It seems in Lollipop, when you try to uninstall an application, it doesn't uninstall for all users (although I only have one user).

I just go to the Apps section in Settings, select the application and use the menu and "Uninstall for all users".



回答12:

I'd had the same problem, after closed Genymotion emulator and connected my phone. Cleaning the project and rerunning solved my problem too.



回答13:

I had the same issue reported here. I recently added a third activity to my application and it was failing to launch with the same error. To fix the issue, I used a detail posted here. Another developer said that introducing an error to their AndroidManifest.xml file corrected their issue. I did the same: I added a space to cause a compile error, built, got the error reported, corrected the error and then recompiled and deployed and IT WORK.

Hope it fixes your issue.



回答14:

One Solution:

Just create a new project and copy your classes from the old project into the new project, run the new project and it will probably work, worked for me.



回答15:

In Android Studio under Run->Edit Configurations check that the package name is correct in the Launch Activity box.

I had an issue with a capital letter in that box that wasn't in the package name.



回答16:

It happened with me because I forget to add it in manifest file or misspell Class name



回答17:

its as simple as just removing the . (dot) in front of your activitys name. Your main activity should not be dotted. Dots in front of the name means its an child of the main one.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!