Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Fragment/ WebViewActivity Error

For some reason now once I click into a blog post title to try and open the post, the app crashes!

02-26 22:26:40.695: E/AndroidRuntime(1277): FATAL EXCEPTION: main

02-26 22:26:40.695: E/AndroidRuntime(1277): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.teamtreehouse.ribbit/com.teamtreehouse.ribbit.BlogWebViewActivity}; have you declared this activity in your AndroidManifest.xml?

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628) 02-26 22:26:40.695: E/AndroidRuntime(1277): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.app.Activity.startActivityForResult(Activity.java:3390) 02-26 22:26:40.695: E/AndroidRuntime(1277): at android.app.Activity.startActivityForResult(Activity.java:3351)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:848)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.support.v4.app.Fragment.startActivity(Fragment.java:878)

02-26 22:26:40.695: E/AndroidRuntime(1277): at com.teamtreehouse.ribbit.NewsFragment.onListItemClick(NewsFragment.java:83)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.widget.AdapterView.performItemClick(AdapterView.java:298)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.widget.AbsListView.performItemClick(AbsListView.java:1100)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2788)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.widget.AbsListView$1.run(AbsListView.java:3463)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.os.Handler.handleCallback(Handler.java:730)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.os.Handler.dispatchMessage(Handler.java:92)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.os.Looper.loop(Looper.java:137)

02-26 22:26:40.695: E/AndroidRuntime(1277): at android.app.ActivityThread.main(ActivityThread.java:5103)

02-26 22:26:40.695: E/AndroidRuntime(1277): at java.lang.reflect.Method.invokeNative(Native Method)

02-26 22:26:40.695: E/AndroidRuntime(1277): at java.lang.reflect.Method.invoke(Method.java:525)

02-26 22:26:40.695: E/AndroidRuntime(1277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)

02-26 22:26:40.695: E/AndroidRuntime(1277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

02-26 22:26:40.695: E/AndroidRuntime(1277): at dalvik.system.NativeStart.main(Native Method)

it asks have you declared this activity in your AndroidManifest.xml? which I have...

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

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" android:name="RibbitApplication">
    <activity
        android:name="com.teamtreehouse.ribbit.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.teamtreehouse.ribbit.LoginActivity"
        android:label="@string/title_activity_login"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="com.teamtreehouse.ribbit.SignUpActivity"
        android:label="@string/title_activity_sign_up"
        android:parentActivityName="com.teamtreehouse.ribbit.LoginActivity"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="com.neils.blogreader.BlogWebViewActivity"
        android:label="@string/title_activity_blog_web_view" >
    </activity>
</application>

</manifest>

1 Answer

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Ah okay, the thing to remember here is that the full, complete name of your class includes the package name. So check out the error statement: it refers to "com.teamtreehouse.ribbit.BlogWebViewActivity:

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.teamtreehouse.ribbit/com.teamtreehouse.ribbit.BlogWebViewActivity

But in your manifest, you have:

android:name="com.neils.blogreader.BlogWebViewActivity"

Which package name matches how you have it declared in your BlogWebViewActivity.java file? I'm guessing the one with your own name. You'll need to fix the import statement in your NewsFragment to import the correct one, and then this error should go away.