29

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:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.foo.app">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".main">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".NoBellsActivity"/>
    </application>
</manifest>

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

LuxuryMode
  • 33,401
  • 34
  • 117
  • 188

19 Answers19

48

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.

Botond Kopacz
  • 925
  • 8
  • 14
  • For me, I renamed my starting activity, but it wasn't updated in the run configurations page. Updating the name fixed my problem. It was tough to find since a "Find in Path" search wouldn't locate the old activity name anywhere. – Rock Lee Jan 29 '16 at 23:20
  • @RockLee that was also my problem.. for me the offending line was in MainActivity.java. – BradByte Apr 08 '16 at 13:36
  • 2
    this is maybe the most common cause of this error, but not the only. – Ninja Coding May 23 '16 at 17:39
16

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

Joff
  • 161
  • 1
  • 2
14

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

Community
  • 1
  • 1
deko
  • 2,534
  • 3
  • 34
  • 48
  • This was it for me. I had uninstalled the app but looking in settings I saw it still listed there but with "Uninstalled". I had to "Uninstall for all users" to remedy this error. – ecnepsnai Apr 01 '15 at 01:10
8

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...

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.

AndroidCuriosity
  • 303
  • 1
  • 3
  • 6
  • 1
    thank you! That fixed my problem. When you change package name, change it in AndroidManifest.xml, build.gradle, MainActivity.java, and the folder hierarchy that MainActivity.java must match the package name. ( I am manually editing all this in a react-native project ) – Ed of the Mountain May 17 '16 at 15:30
  • This is a real solution for my issue, I tried all most everything before taking look at this one. – San Jan 11 '17 at 16:27
5

Rebuild the application and run it.

This solved my problem.

cryptic
  • 168
  • 1
  • 10
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.

Ken
  • 30,811
  • 34
  • 116
  • 155
3

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

Ahmad Baraka
  • 1,093
  • 9
  • 12
1

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".

alonsovb
  • 517
  • 4
  • 14
1

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

mcanvar
  • 465
  • 6
  • 13
1

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.

Delete
  • 922
  • 8
  • 12
1

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.

xaviert
  • 5,653
  • 6
  • 29
  • 31
0

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.

Community
  • 1
  • 1
Sandy Chapman
  • 11,133
  • 3
  • 58
  • 67
0

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.

user1420482
  • 147
  • 3
  • 12
0

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.

Adam
  • 1
0

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

Basheer AL-MOMANI
  • 14,473
  • 9
  • 96
  • 92
0

I tried many but the problem is confliction of the package. I just invalidated caches and restarted my Android studio and working well. Hope this may help you!

Komal
  • 79
  • 1
  • 10
0

Probably this answer is too late, but I have to share my experience. I got this problem while I developed a multi-platform Xamarin app and I was getting:

Error type 3 Error: Activity class {com.companyname.Name/com.companyname.Name.MainActivity} does not exist.

I just solved this issue removing the tag: <category android:name="android.intent.category.LAUNCHER" /> and that's it, problem solved!

NOTE: I'm using a Splash Launcher and that was the reason of my problem, when I added the tag LAUNCHER on my MainActivity all the app crashed.

-3

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.

molden
  • 1
  • Incorrect. The dot is used to signify that the package name specified in the package name in the manifest tag should be prefixed to the class name so you don't have to keep repeating it. – LuxuryMode Aug 05 '13 at 18:39