Make sure you register the new post types before flushing! So call the function that registers them not only on init
, but also in your activation/flush function.
See very first example here: https://codex.wordpress.org/Function_Reference/flush_rewrite_rules.