I am getting this exception while I am trying to call an activity from another one. The complete exception is

android.content.ActivityNotFoundException:Unable to find explicit activity class {com.x.y/com.x.y.class};

I am doing an intent.setClass("com.x.y","com.x.y.className") where className is the name of my activity class and com.x.y is the package it resides in.

My AndroidManifest.xml has the following content:

<activity android:name="com.x.y.className" android:label="@string/app_name">

Am I missing anything?

Solution 1

Maybe you need to check that you added the new activity to the manifest.xml file


      android:label="@string/app_name" > 

Solution 2

If other people are encountering something similar and arrive at this post, an issue I had may save you some time. May not be related to the OP's problem but def related to the ActivityNotFound exception.

I was trying to load an activity by using:

Intent intent = new Intent( this, class );

However I continuously kept getting the ActivityNotFoundException even though I had checked and rechecked the code multiple times.

This exception I was getting wasn't actually being caused by the intent but some code I was running inside the loaded activity throwing a RuntimeException. (my issue was caused by Typeface.createFromAsset())

It is possible you are running into a similar RuntimeException in your activity.

To see if this is the case, put your intent code in try catch blocks. Like so:

try {
    /* your code */
} catch ( ActivityNotFoundException e) {

Run your app again, and check your LogCat, if it's the same issue, you'll get a RuntimeException with a "Caused By:" entry pointing to your actual issue.

I spent a good hour trying to figure this out. Hopefully this may save someone some time.

Solution 3

The activity you are calling should appear not only in the Manifest for its own package, but in the Manifest for the CALLING package, too.

Solution 4

Delete your activity from the manifest and then add it again. This type do not write type the XML directly. Instead, go to Application > Application nodes > add, choose the Activity, and then browse for the file source.

This worked for me.

Solution 5

intent.setClass takes parameters as "Package Context" and "Class". an example would be:

intent.setClass(CurrentActivity.this, TargetActivity.class);

also you need to check if the activity is registered in manifest file.

Solution 6

Added a new activity and defined it in manifest.xml, but I was still getting "Unable to find explicit activity class" error. I am using Eclipse. Solution for my problem was "cleaning" the project. From the main menu in Eclipse: Project|Clean.... Then you select your project and clean it.

Solution 7

Hey, you need to use another form of Intent constructor. This will surely solve your issue within a second:


Intent inte=new Intent(getBaseContext(),"your class name with .class extension ");


This works perfectly and I checked this code, its working properly.

Solution 8

I had an ActivityNotFoundException when I implemented the Activity inside another class (as an inner class):

//... inside the utility class Pref
public static class Activity extends PreferenceActivity {
    protected void onCreate(Bundle savedInstanceState) {

Declared as the following inside the manifest:

<activity android:name=".Pref.Activity"

After declaring this as a normal class (public class PrefActicity) and changing manifest accordingly, it worked as usual.

Solution 9

I was using getActivityContext() (instead of Activity.this) for the menu code to save some work, and copy-and-paste it to each activity without editing each time.

I replaced them with Activity.this, and the issue is gone.

I have a feeling a smarter Android guy could work-around not having to do that. Would like to hear what it would be.

Solution 10

Looking at the documentation here what you want is:

intent.setClassName("com.x.y", "className");

Solution 11

Restart the Eclipse and check your Manifestfile again. If you find missing the respective Activity, then add it and try again. It solved my similar issue.

Solution 12

In addition to Mina's answer. When you declare activity as inner static class then you should write your activity into manifest like ...

         <activity android:name=".app.FragmentLayoutSupport$DetailsActivity" />

here .app comes from your package name , it can be .helpers.afdfa$afda

Solution 13

My solution to this error was to add a package name in front of the name in manifest.

I had the following activities:

  • id.scanner.main.A1


My manifest contained the following:

<activity android:name=".A1" ....></activity>
<activity android:name=".A2" ....></activity>

This solved the problem:

<activity android:name=".A1" ....></activity>
<activity android:name="gallery.A2" ....></activity>

Solution 14

Yeah I got this problem too. I refreshed the project. And then, everything works fine.

Solution 15

when i have same issue. if you are using library class files and writing it into android manifest files write it like and then remove the library projects manifest files this portion>> then it will work absolutely..

Solution 16

This exception also occurs if you include a library in your app and if the library is calling an activity defined in the library project. In this case we need to merge library's manifest with calling app's manifest.

With ADT version 20, we can do this by adding the below statement in of calling app.


Solution 17

Check out the content of the Android Manifest File in the bin folder of the project. When your app is compiled and packaged the Manifest File is copied to the bin folder. In my case the Manifest in the bin folder did not agree with the original Manifest. This is probably a mistake of Eclipse. I manually copied the Manifest to the bin folder and it worked.

Solution 18

you can add this code in manifiest.xml file

action android:name="com.kaushalam.activity101activity.SecondActivity"
category android:name="android.intent.category.DEFAULT"

Solution 19

I got the same case too. After reading thepearson's answer, I revised my Activity and found out that I wrote

public void onCreate(Bundle s)

But in fact it should be

protected void onCreate(Bundle s)

And it works now!

Solution 20

This works if you have an Activity object (which you need to launch):

intent.setClassName(CallingActivity.this, activityToLaunch.getComponentName().getClassName());

Solution 21

Activity you're calling sholdn't contain "sheme" and contain intent-filter:

<activity android:name=".SecondActivity">
               <action android:name=""/>
               <category android:name="android.intent.category.DEFAULT"/>

so in calling code:

Intent intent=new Intent("");

Solution 22

Try using the following:

intent.setClassName("com.x.y", "com.x.y.className");

This works for me

Solution 23

I also ran into ActivityNotFoundException by passing the wrong view into setContentView(), each activity's class file must correspond with the layout xml file this way.

protected void onCreate(Bundle savedInstanceState) {

as opposed to

protected void onCreate(Bundle savedInstanceState) {

Solution 24

I had the same issue. I tried everything but the error, which I sorted out later, was that there was a space left between double quotes and my class name. It has to be: intent.setClassName("com.x.y","com.x.y.className")


intent.setClassName("com.x.y","  com.x.y.className")