Android Settings App: I Can only target elements by xpath


when I am in the android settings app (settings of app to control notifications) I can only target the elements by xpath, and not by the id (accessabilityId ?).

Relevant code:

const settingsStatusHeaderElement = await Element.getElement(
     this.settingsAppHeaderIdentifier, // tried xpath, id
     this.settingsAppHeaderAccessorType // tried xpath, id or accessabilityId
await settingsStatusHeaderElement.isExisting();
await settingsStatusHeaderElement.isDisplayed();

Log file says this:

invalid selector: The selector “” used with strategy “css selector” is invalid! For more information on selectors visit the WebdriverIO docs at:
at processTicksAndRejections (node:internal/process/task_queues:96:5)

This is how the element is targeted

public static async getElementByAccessibilityId(id) {
    return $(`${id}`);

public static async getElementByXpath(xpath) {
    return $(xpath);

public static async getElementById(id) {
    return $(`#${id}`);

Hi I might have had the same problem using the javascript code generated by appium inspector.
Generated code: let el1 = await driver.$("android:id/switch_widget");
This got me: ERROR webdriver: Request failed with status 400 due to invalid selector
And on the appium server: Encountered internal error running command: InvalidSelectorError: Invalid CSS selector 'android:id/switch_widget'. Reason: 'css-selector-parser parse error: Expected rule but "/" found. ...
Adapting the generated code in one of the following ways worked:

//xpath locator
let el1 = await driver.$('//*[@resource-id="android:id/switch_widget"]');
//id strategy
let el1 = await driver.$("id=android:id/switch_widget");