Yes! You can swap a 2.5L 2arfe into a older 2.4L car . Do NOT rebuild the 2.4L it is not worth it unless want keep the same engine for resale, but again not worth it as the 2.4l are junk engines and people know now not to buy them. A scion 2.5L 2arfe can be had for cheaper than a rebuild or cheaper than a rav4 2.5L.
The scion 2.5L 2arfe engines can be had with low miles in junk yard for $250 to $1000.
This scion 2.5L 2arfe can also be swapped in place of the very hard to find expensive to replace 2.7L 1arfe which came in the venza, highlander, sienna. There are certain parts will have to reuse on the swap of any kind but the scion 2.5L bolts up and plugs in no problems.
There are videos on you tube showing it is far cheaper to use scion 2.5l to replace a 2.4L, 2.7L or other 2.5L if original engine is bad.