1

I'm trying to make a simple program where if I go and click a button in my app a new activity pops up that asks to input a browser. Here's the Exception I keep recieving:

02-26 04:38:11.900 1937-1937/? E/AndroidRuntime: FATAL EXCEPTION: main
    android.content.ActivityNotFoundException: Unable to find explicit activity class
        {com.course.example.widgets/com.course.example.widgets.WebLookup};
    have you declared this activity in your AndroidManifest.xml?
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
        at android.app.Activity.startActivityForResult(Activity.java:3370)
        at android.app.Activity.startActivityForResult(Activity.java:3331)
        at android.app.Activity.startActivity(Activity.java:3566)
        at android.app.Activity.startActivity(Activity.java:3534)
        at com.course.example.widgets.Widgets.onClick(Widgets.java:139)
        at android.view.View.performClick(View.java:4204)
        at android.view.View$PerformClick.run(View.java:17355)
        at android.os.Handler.handleCallback(Handler.java:725)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5041)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
        at dalvik.system.NativeStart.main(Native Method)

Here's my manifest xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.course.example.widgets"
      android:versionCode="1"
      android:versionName="1.0">

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Widgets"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.course.example.widgets.WebLookup"
                    android:label="@string/app_name"/>
    </application>
    <uses-sdk android:minSdkVersion="17" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
</manifest> 

Here's the code that actually starts the activity:

case R.id.webButton:{
    Intent webLookup = new Intent(this, WebLookup.class);
    startActivity(webLookup);
    break;

It's in a switch block that is for determining 3 other button actions but I didn't think it was relevant.

Here's a picture of XML file and my two Java files in navigator on left.

enter image description here

thorin86
  • 604
  • 11
  • 26
Taylor Handy
  • 93
  • 1
  • 12
  • 4
    Disregard the two existing answers. Please tell us the capitalization you used in the actual file name for your class and show us the capitalization you used in the class name of your class. – Stephan Branczyk Feb 26 '16 at 06:31
  • Possible duplicate of [...have you declared this activity in your AndroidManifest.xml](http://stackoverflow.com/questions/15699192/have-you-declared-this-activity-in-your-androidmanifest-xml) – Aditya Vyas-Lakhan Feb 26 '16 at 06:32
  • You have to provide complete package name. – Ashish Ani Feb 26 '16 at 06:33
  • Thank you, for the input however I tried putting the complete package name as shown above and it still doesn't work – Taylor Handy Feb 26 '16 at 06:42

5 Answers5

2

Declare this Activity to AndroidMenifest, you error might be have not written package name before activity name

<activity
            android:name=".WebLookup" //write package name before activity name
            android:configChanges="orientation" //optional
            android:screenOrientation="portrait" //optional
            android:windowSoftInputMode="adjustResize" /> //optional
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
2

If you have not included the package path at the top of the class you wont be able to reference it in the manifest, e.g. enter image description here

FluffyKitten
  • 13,824
  • 10
  • 39
  • 52
Abilsdon
  • 21
  • 2
1

If you are adding this activity class manually, verify that the class is set to public. This way the AndroidManifest.xml should automatically show your activity class as a possible option.

public MyActivityClass extends AppCompatActivity{
...
}
Alex
  • 11
  • 1
0

use

<activity android:name="com.course.example.widgets.WebLookup"
                    android:label="@string/app_name"/>

the full name of the activity is much more comfortable in practice.

com.course.example.widgets.WebLookup mean the full path to your Activity class file.

Vyacheslav
  • 26,359
  • 19
  • 112
  • 194
-1

You have to provide complete package name like this

<activity android:name="com.course.example.widgets.WebLookup"
                    android:label="@string/app_name"/>

Otherwise it will not detect your class whom to transfer the intent.

Ashish Ani
  • 324
  • 1
  • 7