2

I have searched around about PreferenceActivity having to override the isValidFragment method, and I understand the concept, but when I override that method I get an error that says: Method does not override method of its super class. Why is it not finding that method in the superclass?

For now I just tried to return true (I know that's not the way it's supposed to be done, but I can fix that later when I get it to work)

public class SettingsMenu extends PreferenceActivity
{
...

    @Override
    protected boolean isValidFragment (String fragmentName)
    {
        return true;
    }
}

When I do it this way, the @Override gets a red underline, and the error referenced above it what I see when I hover over the underline.

For the time being I have lowered the targetapi to 18 so that the method is not required, but I know that's not a good fix due to security issues.

Randy
  • 1,068
  • 2
  • 14
  • 32

2 Answers2

2

Set your build target (e.g., Project > Properties > Android in Eclipse, compileSdkVersion in build.gradle) to API Level 19 or higher. My guess is that yours is set to something lower than that.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

I was also having this problem. Your question helped me decide I wasn't going crazy. In my case it turned out my Project's Android Project Build Target was set at Android 4.0.3 / API Level 15 (my minSdkVersion) but it seems to need to be Android 4.4.2 / API Level 19 (the targetSdkVersion).

To set the Project Build Target:

  • Project Properties / Android / Project Build Target - check Android 4.4.2.
  • Click Apply and OK
    • Eclipse will want to rebuild
  • Restart Eclipse / ADT

After finding this answer out myself, I also found the following answer which reinforced the expectation that the Project Build Target should match targetSdkVersion Difference between "Build Target SDK" in Eclipse and android:targetSdkVersion in AndroidManifest.xml?

The developer reference for targetSdkVersion seems to be http://developer.android.com/guide/topics/manifest/uses-sdk-element.html, but I couldn't find a specific reference that the project's build target NEEDS to match targetSdkVersion.

FWIW another clue to this answer was when I tried also setting minSdkVersion to 19. Eclipse then reported a warning on the AndroidManifest.xml that 'Attribute minSdkVersion (19) is higher than the project target API level (15)'. It was this clue that made me realise I was on the right track, but should look at the Eclipse project settings.

After posting I realised Mark's answer is the same, but his brevity wasn't clear to me until now.

Community
  • 1
  • 1
troutit
  • 23
  • 4