Struggling to counter early mass hand infantry

In a few recent games I’ve played against the Inca and Swedish I’ve really struggled to counter age two hand infantry. The obvious counter in my mind being light infantry behind a small meatshield of pikes or what few cav i can ship or produce but no matter which units I use i find them just being overrun. Is there a method that doesn’t require me booming behind walls until I can build up a large army to shield mass artillery?