-2

I get the following error:

FATAL ERROR : main have you declared this activity in your AndroidManifest.xml?

I don't know how to declare my activity. This is my androidmanifest.xml

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

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="info.androidhive.slidingmenu.MainActivity"
            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="info.androidhive.slidingmenu.speak1"/>
    </application>
<uses-permissions></uses-permissions>
</manifest>

Where should I put the declaration of my activity? and this is my speak1.java *i've edited my speak1.java

package info.androidhive.slidingmenu;    
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class speak1 extends Activity { 
     @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.speak1);     
     }
     }

3 Answers3

2

As in log not declaring speak1 Activity in AndroidManifest.xml. Add speak1 Activity in Manifest using activity attribute :

 <activity
        android:name="info.androidhive.slidingmenu.speak1" />

EDIT:

public class speak1 extends Activity { 
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.speak1);     
 }
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
  • but, it doesn't work the log cat says 05-15 10:35:58.479: E/AndroidRuntime(533): FATAL EXCEPTION: main 05-15 10:35:58.479: E/AndroidRuntime(533): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{info.androidhive.slidingmenu/info.androidhive.slidingmenu.speak1}: java.lang.ClassCastException: info.androidhive.slidingmenu.speak1 cannot be cast to android.app.Activity 05-15 10:35:58.479: E/AndroidRuntime(533): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880) – Siska Vadilah May 15 '15 at 03:36
  • @SiskaVadilah: Add `` in log – ρяσѕρєя K May 15 '15 at 03:37
  • @SiskaVadilah: and id still not working then post updated `AndroidManifest.xml` and `PagesFragment$1.onClick` method code – ρяσѕρєя K May 15 '15 at 03:37
  • @SiskaVadilah: What is `speak1` classs is this class extending Activity or it is a Fragment ? – ρяσѕρєя K May 15 '15 at 03:38
  • 1
    @SiskaVadilah: instead of making comment please update all code in question – ρяσѕρєя K May 15 '15 at 03:40
  • it still doesn't work 05-15 11:06:18.280: E/AndroidRuntime(525): FATAL EXCEPTION: main 05-15 11:06:18.280: E/AndroidRuntime(525): android.app.SuperNotCalledException: Activity {info.androidhive.slidingmenu/info.androidhive.slidingmenu.speak1} did not call through to super.onCreate() 05-15 11:06:18.280: E/AndroidRuntime(525): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1922) 05-15 11:06:18.280: E/AndroidRuntime(525): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) – Siska Vadilah May 15 '15 at 04:07
0

As per your error, you should be declared activity speak1 in manifest file. Then clean and build your project.

Be sure speat1 extends Activity also.

Garima Mathur
  • 3,312
  • 3
  • 18
  • 32
0

As seeing your Logcat their is ClassCastException coming. this means you are casting to something which is not correct. Casting means changing datatype Like casting int to string or something like this. you should post your entire code. Pls check for anything related to casting Hope this solve your problem.