Shane Black’s movie is an affectionate parody of the sort of mismatched-buddy action comedies that proliferated in the seventies and eighties, better than most of them were. The joke is that while “The Nice Guys” isn’t nice at all, spinning a plot that’s as cynical and labyrinthine as “Chinatown” or “L.A. Confidential” (very different sorts of period pieces), it does so with a jovial nastiness that’s well-nigh irresistible.

A good deal of the reason for the picture’s success is Black’s script. Its recreation of the milieu of 1977, when it’s set, isn’t pitch-perfect—gas lines occurred in 1973 and 1979, but not 1977, for instance—but it gets the general ambience right. Though its complications get so tangled, especially in the last third, that you might throw up your hands trying to sort them all out, that’s part of the humor of the homage. And the dialogue and situations are clever, particularly when well played and delivered.

That brings one to the second main positive ingredient—the pairing of Russell Crowe and Ryan Gosling. On the surface they might seem an unlikely coupling, both better known for drama than comedy and, on the surface at least, not having a great deal in common. But here each demonstrates a real flair for farce, and they work together like a seasoned team.

“The Nice Guys” starts with a hilariously over-the-top prologue in which a car careens through a hillside house to the amazement of a young boy inside, coming to rest to reveal its dying driver—a luscious porn star named Misty Mountains (Murielle Telio). Then it moves on to its stars. Crowe, with fifty or so extra pounds added to his already burly frame, is Jackson Healy, is a fixer who employs his fists—usually outfitted with brass knuckles—to handle problems for clients. At the moment he’s been hired by a young lady named Amelia (Margaret Qualley) to scare off a guy who, she claims, is following her. The fellow turns out to be Holland March (Gosling), a boozy private eye who specializes in fleecing his (preferably elderly) clients while his precocious daughter Holly (Angourie Rice) looks on disapprovingly. He’s in the employ of Misty’s grandmother (Lois Smith), who claims to have seen the dead woman a couple of days after her demise.

Healy roughs March up, but after he’s in turn accosted by a couple of thugs (Beau Knapp and Keith David), they’re working together—their rapprochement cemented in a hilarious bathroom scene in which Gosling exhibits delicious skill at physical comedy—to track down Amelia, a girl with a penchant for socially-conscious causes. The investigation will take them to the burned-out house of her dead boyfriend, with whom she made a mysterious “experimental” film; to a lavish party thrown by the movie’s porno producer, who turns up dead; and to the office of Judith Kutner (Kim Basinger), the head of the state’s Justice Department, who turns out to be Amelia’s mother and also wants her found. As they continue the search, however, they fall afoul of a slickly efficient hit-man called John Boy (Matt Bomer). The plot winds up at a car show where the new models are being exhibited at the same time that a controversy about whether they should be equipped with smog-reducing catalytic converters is being litigated.

It’s unlikely that most viewers will be able to tie all the plot threads together, and the ultimate conspiracy scenario is pretty loopy, considering what we now know of the US history. But it doesn’t really matter. “The New Guys” is no thriller, and the lapses of logic are frankly inconsequential. The movie is essentially a cinematic version of an extended vaudeville routine for Crowe and Gosling, and on that simple basis it works agreeably. Crowe doesn’t downplay the possibility that Healy can suddenly turn homicidal, but he gives the shambling bruiser the air of a lovable lug, and his barely disguised exasperation with March is priceless. Gosling provides an engaging contrast. March is unprincipled but devoted to his daughter, and Gosling plays his doofus side to perfection. At one point he channels Lou Costello for an extended reaction scene and nails it, while Crowe’s Bud Abbott looks on incredulously. The physical attributes might be switched, but the thin-chubby relationship is still there—just in reverse.

But it’s not just the stars who shine here. Rice proves an agreeable helper, never allowing Holly’s precociousness to become obnoxious. Bomer turns his matinee-idol good looks to the sinister side with aplomb. Yaya DaCosta invests Kutner’s aide-de-camp with seventies style, and while neither Qualley nor Basinger quite hits the mark, there are plenty of others to compensate: Knapp and David, with a swagger that suggests an overheated take on “Wait Until Dark,” Jack Kilmer as a goofball projectionist, and even Lance Valentine Butler, in what amounts to a cameo as an on-the-make kid on a bike. Among the craft credits Philippe Rousselot’s widescreen cinematography catches the seedy glitz in Richard Bridgland’s period production design, but it’s probably Kym Barrett’s garish costumes, along with the jauntily retro score by David Buckley and John Ottman and the pop song selections (not always chronologically correct, but who cares?) that will grab audiences most.

Think of “The Nice Guys” as “Inherent Vice” for the masses. It’s a less rarefied, more crowd-friendly spoof of old formulas than Paul Thomas Anderson’s film, but no less successful in evoking the spirit of movies that might not have always been great, but were usually dumb fun. This one is, too.