Gadget base (better 're-base')

dear all, I am trying to setup a custom ubuntu core image for Raspberry CM4; I need to use my custom gadget snap but if I try to include it, using something like the following in the .json file

.....
  "base": "core22",
  "grade": "dangerous",
  "snaps": [
   {
     "name": "my-gadget",
     "type": "gadget",
     "default-channel": "latest/stable",
     "id": "......."
   },
....

I get this message:

error: cannot use gadget snap because its base "core18" is different from model base "core22"

is there a way to rebase the custom gadget?

I tried to recompile it changing in its snapcraft.yaml file the base attribute but I got the same error message.

You will likely not get away with just changing the base.

snapcraft.yaml syntax and features typically change with new bases, so you will need to make sure the whole file uses the newer format/features.