views:

196

answers:

5

What is wrong with piece of code?

@Override
protected void onCreate(Bundle savedInstanceState) {

Eclipse states that @override cant be where it is. It says that 'Bundle' is wrong. I am lost.

+1  A: 

it should be

 @Override public void onCreate(Bundle savedInstanceState){

 }

onCreate is public, not protected.

Eclipsed4utoo
Actually... `onCreate()` is `protected`: http://developer.android.com/reference/android/app/Activity.html#onCreate%28android.os.Bundle%29
fiXedd
I came back with your corrections but it still won't work. I will redownload the SDK. And try again. Thanks.
Baleisen
I reasked the question and included the code.
Baleisen
+1  A: 

So maybe the problem is compiler compliance level: 1.5 instead of 1.6 ?

@Baleisen which level is set for your project?

Ramps
A: 

What your class extends ? And which android SDK version you're compiling ?

Alex Volovoy
+1  A: 

I don't know much about the android framework but:

First make sure your class extends a Class such as (Activity) which contains onCreate. Then try to call super.onCreate, to double check that Class you are extending contains onCreate! You could be pointing to another class with the same name. Your compiler says that there is nothing to override, if you are sure it is wrong, then either your compiler is out dated or the framework.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //yourCode
    }

Also if your extending and extended class, make sure, this method, I posted is in the class extending the class. It could freak out on this.

Andrew
A: 

This has happened to me before and the problem was the Android SDK hadn't loaded into Eclipse fully.

Also, do you have this import in your file? The parent onCreate method is in Activity.

import android.app.Activity;
Austyn Mahoney