1

When i try to compile the following code using javac or gradlew

I got the error method does not override or implement a method from a supertype @Override The error happened to the two @Override functions

How to solve that ?

code.java:

package com.android.commands.locksettings;

import android.os.ResultReceiver;
import android.os.ServiceManager;
import android.os.ShellCallback;

import com.android.internal.os.BaseCommand;
import com.android.internal.widget.ILockSettings;

import java.io.FileDescriptor;
import java.io.PrintStream;

public final class LockSettingsCmd extends BaseCommand {

    private static final String USAGE =
            "usage: locksettings set-pattern [--old OLD_CREDENTIAL] NEW_PATTERN\n" +
            "       locksettings set-pin [--old OLD_CREDENTIAL] NEW_PIN\n" +
            "       locksettings set-password [--old OLD_CREDENTIAL] NEW_PASSWORD\n" +
            "       locksettings clear [--old OLD_CREDENTIAL]\n" +
            "\n" +
            "locksettings set-pattern: sets a pattern\n" +
            "    A pattern is specified by a non-separated list of numbers that index the cell\n" +
            "    on the pattern in a 1-based manner in left to right and top to bottom order,\n" +
            "    i.e. the top-left cell is indexed with 1, whereas the bottom-right cell\n" +
            "    is indexed with 9. Example: 1234\n" +
            "\n" +
            "locksettings set-pin: sets a PIN\n" +
            "\n" +
            "locksettings set-password: sets a password\n" +
            "\n" +
            "locksettings clear: clears the unlock credential\n";

    public static void main(String[] args) {
        (new LockSettingsCmd()).run(args);
    }

    @Override
    public void onShowUsage(PrintStream out) {
        out.println(USAGE);
    }

    @Override
    public void onRun() throws Exception {
        ILockSettings lockSettings = ILockSettings.Stub.asInterface(ServiceManager.getService("lock_settings"));
        lockSettings.asBinder().shellCommand(FileDescriptor.in, FileDescriptor.out,
            FileDescriptor.err, getRawArgs(), new ShellCallback(), new ResultReceiver(null) {});
    }
}
5
  • 2
    Show us the code of your BaseCommand class, please...
    – deHaar
    Commented Mar 13, 2019 at 11:35
  • 1
    I was using a fake BaseCommand file to avoid compilation errors, Now i get the original file and working good, Thanks
    – John
    Commented Mar 13, 2019 at 12:03
  • Wonderful... Let me guess: The fake file was empty?
    – deHaar
    Commented Mar 13, 2019 at 12:06
  • @deHaar If the file would be empty then error should not appears Commented Mar 13, 2019 at 12:08
  • @RafałSokalski ok, ok... what I meant was: the overridden methods were not present.
    – deHaar
    Commented Mar 13, 2019 at 12:08

1 Answer 1

1

Solved by restoring original BaseCommand file, Thanks to @deHaar

Not the answer you're looking for? Browse other questions tagged or ask your own question.