0

I have recently picked up a project from a few months ago. Went to re-open the project and found a few of the following errors:

public void onCreate(Bundle savedInstanceState) {

Gives the error: The method onCreate(Bundle) of type myMain must override or implement a supertype method

super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);

Gives the errors: The method onCreate(Bundle) is undefined for the type Activity and The method onCreate(Bundle) is undefined for the type Activity.

@Override
protected void onPause() {

Gives the error: The method onPause() of type myMain must override or implement a supertype method

I have created a new project with identical code for the first section (see code block 2) and do not receive any errors. I am certain it is a small config/code change I cannot pin down that will solve all these problems in one sweep.

Full code is: package com.myapp.app;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;

public class myMain extends Activity {

MediaPlayer mpSplash;

@Override
// onCreate works like in the activity diagram from tutorial.
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);

    mpSplash = MediaPlayer.create(this, R.raw.logo_noise);
    mpSplash.start();
    Thread logoTimer = new Thread()
    {
        public void run()
        {
            try{
                int logoTimer = 0;
                while(logoTimer < 2000)
                {
                sleep(100);
                logoTimer = logoTimer +100;
                }
                startActivity(new Intent ("com.myapp.app.CLEARSCREEN"));
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            finally{
                finish(); // shut down class
            }
        }
    };
    logoTimer.start();
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
}

@Override
protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    mpSplash.release();
}

@Override
protected void onRestart() {
    // TODO Auto-generated method stub
    super.onRestart();
    mpSplash.pause();
}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    mpSplash.start();
}

@Override
protected void onStop() {
    // TODO Auto-generated method stub
    super.onStop();
}

}

CODE BLOCK 2

import android.app.Activity;
import android.os.Bundle;

public class myMain extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

I have searched around and found mainly overly complex and unrelated issues such as: import of android.r Updating the build path Re-importing the project creating new references to classes. Configuring proguard? None of the above have seemed to work.

Any help that anyone could provide on this issue would be greatly appreciated.

user1228891
  • 636
  • 8
  • 17

2 Answers2

0

Try to clean your project Project -> clean, if this don't solve it. I think the problem is that you're compiler settings are set to Java 1.5 instead of Java 1.6. go to Windows -> Preferences -> Java -> Compiler and the change Compiler compliance level to 1.6

K_Anas
  • 31,226
  • 9
  • 68
  • 81
0

I have recently picked up a project from a few months ago. Went to re-open the project and found a few of the following errors.

If your code was working before w/o errors, then it definitely should be working now without errors. I am not sure why you posted all of your code in your post, for this reason...

Make sure you haven't moved the android SDK folder (android-sdks by default). This will cause eclipse to throw errors like you are describing, because it won't be able to find the framework classes such as Activity, etc.

The method onCreate(Bundle) of type myMain must override or implement a supertype method.

This error means that eclipse thinks that onCreate is not a defined method in the Activity class. This leads me to believe that your either your eclipse install is outdated, eclipse can't find the SDK class files, or your eclipse install is just totally messed up. Make sure you have the latest version of the ADT plugin (revision 18). If that doesn't work then just create a new project... it's not worth trying to figure out what went wrong if you can just start from scratch.

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
  • Hi Alex, I had moved the folder, but I have entered the new location in eclipse under - Windows > preferences > Android. Pointed to the correct folder and selected the most up to date version of 2.2. I think you are definitely onto something with this. The one thing throwing me off is that it seems to work for other projects? Aside from changing the general SDK location, is there anything similar you would need to do for a specific project which could be causing this issue? – user1228891 Jun 23 '12 at 20:17
  • Ahhhh, I have no idea... but once you start moving around folders like that things begin to get really messy. Could you perhaps move the folder back to where it was before? I'm sure there is a way to move the android sdk folders correctly, but to do so you should start the (possibly endless journey) with a correctly working eclipse. This kind of stuff could potentially waste a lot of your time... simply uninstalling the ADT/Android plugins and then re-installing the SDK might even be faster to figure out haha. Try moving the folder back to where it was before and updating the preferences? – Alex Lockwood Jun 23 '12 at 20:24
  • I could do that, but the thing is, it is working for new projects, so I think re-installing it would not fix anything... it is something wrong with the particular project. I could just start over, but this has happened a few times now when moving machines/reformatting etc. I'd like to get it pegged down. – user1228891 Jun 23 '12 at 20:36
  • Just choose a permanent place to store your `android-sdks` directory. And I would start over to be honest. Banging your head over the specific workings of the Android project and how it integrates into eclipse does not sound like a walk in the park lol. – Alex Lockwood Jun 23 '12 at 20:39
  • Hey Alex, I've created a clean install of eclipse and the java SDK. Re-connected everything and imported the project....seems to have worked. Will put it down to something gone wrong hidden in eclipse, but it did solve the issue so thank you! – user1228891 Jun 25 '12 at 18:03
  • Haha, sounds good... yeah I wouldn't suggest trying to mess around with the internal workings of eclipse... the IDE doesn't seem to work very well as it is :P – Alex Lockwood Jun 25 '12 at 18:15