java.io.ioexception: open failed: einval (Invalid argument) when saving a image to external storage
The string url
contains illegal characters for a filename. You'll need to cleanup the filename by removing the illegal characters.
Really tricky error since Android 28 works just fine when trying to write a filename with ? or : in the name, but Android 22 for instance would blow up. Just run a couple of replacements in the filename like:
File(filename.replace(":", "").replace("?", "") [...])
and then you're good to run
file.createNewFile()