LINDSEY BAHR

LOS ANGELES - In late July 2014, Danny DeVito started trending on social media after a few people snapped shots of him walking around Manhattan with a dachshund wearing a yellow polka dot dress. The dachshund was in the dress, not DeVito, but it was still quite a sight.

He later explained to Jimmy Fallon that it was in fact for a movie, indie auteur Todd Solondz’s “Wiener-Dog,” which hits theaters in limited release Friday. Let’s just say that the joy of that image takes on a vastly different tone in the actual film, where DeVito plays a sad sack screenwriting professor whose life is a series of escalating disappointments. It’s one of the vignettes in the film, which chronicle the pup’s time with different owners (the others are Julie Delpy and Tracy Letts, Greta Gerwig and Ellen Burstyn).

DeVito, 71, is seated in his trailer on the Fox Studios lot where he’s filming season 12 of the FXX comedy “It’s Always Sunny in Philadelphia.” He’s had the trailer for 20-some years — it’s his second and it’s a reminder of the stark contrast between a well-oiled sitcom and an indie.

“It was a ‘no budget film.’ It wasn’t even a low budget film. There was no money. I’m used to … I mean, look at where I am,” he says gesturing to the lived-in trailer that’s easily as big as an apartment. “This is where I go between takes. I have a bathroom. I have a bedroom … On ‘Wiener-Dog,’ we peed in bodegas.”

He loves the film, Solondz and the experience, even if his canine companion proved to be a little trying at times. Their first scene together was supposed to be a simple shot taken from two angles of DeVito picking out the yellow dress at a store and showing it to the dog.

“The dog did not stop moving. Never ever looked at the costume. Never looked at me. Looked at the trainer, went over here, went over there. I think I showed the costume to the dog 40 times. We finally got it, but the dog was, you know,” DeVito said laughing. “I’ve worked with dogs and cats! In ‘The War of the Roses,’ we had a dog chasing a cat. A lot of the times it works out. This dog? This dog was tough. After about a half hour I said to Todd, ‘note to self, first find dog that listens to you, then write the script!’ ”

And then there’s his character, whose name even sounds like a downer — Dave Schmerz. His students don’t respect him. His agent won’t return his calls. And his life is just one painfully banal blow after another. It’s an unexpected dramatic turn that will punch you in the gut, and from an actor that we thought we all knew pretty well by this point.

DeVito’s a little more hopeful than Dave.

“I always thought of the guy who won the Oscar for ‘The King’s Speech’ when I was looking at Dave,” DeVito said of David Seidler, who was in his 70s when he won his first. “You can’t give up!”

He’s also not giving up on Bernie Sanders, who he’ll stick with until the convention, or the country for that matter. Gripping his well-worn “Democracy Now!” baseball cap, he talks passionately about the power of the people to change things.

“I marched in the street not to go to Vietnam. Ultimately they didn’t take me. But the only way you can stop things is people. People have to get together,” he said.

DeVito is still as curious and engaged as ever, dropping theories and facts from books like Jared Diamond’s “Gun, Germs, and Steel,” Yuval Noah Harari’s “Sapiens: A Brief History of Humankind” and a recent “Fresh Air” episode about gerrymandering.

He’s got other projects brewing too, like “The Comedian,” a Taylor Hackford comedy with Robert De Niro, Cloris Leachman, Patti LuPone and Edie Falco, that’s in post-production, and the long gestating “Triplets,” which would be a sequel to “Twins.” The one he’s most excited about, however, is “Asbury,” which would take him back to his hometown in New Jersey and into the director’s chair again.

“It’s basically the story about getting out. It’s timeless,” he said. “I’m not sure exactly when I’m going to shoot it, but I want it to be right before I start.”

“It’s Always Sunny...” shoots for a swift 12 weeks and then DeVito is free to travel, maybe look for another play to do and figure out what’s next. The show has already been renewed for two more seasons, too.

“I’m not going to stop until I have to,” he said. “There’s only one deadline.”