There's no question that the retail industry is in upheaval. Retailer bankruptcies are soaring, store closings are becoming commonplace, and profits at a wide variety of retail chains are in decline. Retailers are on pace to close more stores this year than in 2008. Let that sink in.

The rise of e-commerce, particularly the aggressive expansion of Amazon.com (NASDAQ:AMZN), is often blamed for this turmoil. E-commerce sales have been consistently growing at a double-digit pace, eating up an increasing percentage of total retail sales. E-commerce is certainly a threat to traditional retailers, but it's not the core problem. Case in point: total adjusted retail sales excluding e-commerce have increased on a year-over-year basis every single quarter since 2010.

A chart showing year-over-year U.S. adjusted retail sales growth excluding e-commerce from 2010 through the second quarter of 2017.

Chart by author. Data source: United States Census Bureau.

So why are retailers having so much trouble? There are simply too many stores. Retail square footage per capita in the U.S. has grown to more than six times that in Europe and Japan. Our car-centric culture probably has something to do with it, but there's little question that there's an excessive number of stores. Add in the impact of e-commerce, and you get the current "retail apocalypse."

This retail upheaval is a lot like a forest fire, destructive in the short term, but ultimately beneficial in the long run. The weakest retailers, unable to turn a profit during anything but the best of times, are failing left and right. Other retailers, having overbuilt stores in the preceding years, are downsizing. The end result of all of this will be a stronger, healthier retail industry, sized more appropriately to actual sales and comprised of retailers capable of adapting.

The market has punished retailers of all stripes, regardless of how likely they are to survive. This creates an opportunity for investors to buy shares of the best retailers for beaten-down prices. How can you tell which retailers are likely to survive? Here are my two rules for investing in the retail apocalypse.

A vacant store and parking lot.

A vacant store. Image source: Getty Images.

1) Avoid excessive debt like the plague

Too much debt isn't a problem when sales and profits are booming. But when things take a turn for the worse, that debt turns into an anchor that can drag a retailer into the abyss. J.C. Penney (NYSE:JCP), the struggling department store chain, would be a profitable company if not for its excessive debt load. About $4.5 billion of debt required interest payments of roughly $360 million last year, completely wiping out the company's operating profit.

Ideally, the balance sheet should have no debt, or a net cash position large enough to weather any storm. A few examples of retailers with fortress balance sheets are Best Buy (NYSE:BBY), Foot Locker (NYSE:FL), and American Eagle (NYSE:AEO).

Retailer

Total cash minus total debt

Annual sales (2016)

Best Buy

$2.25 billion 

$39.5 billion 

Foot Locker

$922 million 

$7.77 billion 

American Eagle

$225 million 

$3.61 billion 

Data source: Best Buy, Foot Locker, and American.

All three of these companies face challenges. Best Buy, after completing a successful turnaround over the past few years, now needs to find a way to grow earnings without the benefit of easy cost cuts. Foot Locker, a major seller of Nike products, is facing a world where footwear sales are shifting online, and where Nike is selling directly on Amazon. And American Eagle, one of many apparel chains, is up against intense competition, as well as Amazon's aggressive push into apparel.

But a strong balance sheet gives a retailer time to adapt. On the flip side, a debt-ridden balance sheet eats away at profits and makes it more difficult for a retailer to make the investments necessary to survive. J.C. Penney, Macy's (NYSE:M), and Sears Holdings are three examples of retailers with excessive debt.

Retailer

Total cash minus total debt

Annual sales (2016)

J.C. Penney

($3.75 billion)

$12.5 billion 

Macy's

($5.53 billion)

$25.8 billion 

Sears Holdings

($4.02 billion)

$22.1 billion 

Data source: J.C. Penney, Macy's, and Sears Holdings.

One problem is easier to deal with than two. If you want to invest in retail, stick with companies that aren't overloaded with debt.

2) Get serious about e-commerce

Online sales are going to continue to grow as a percentage of total retail sales. Traditional retailers need to embrace this shift in order to survive. Companies that treat e-commerce as a second-class citizen are going to be left behind.

Wal-Mart (NYSE:WMT) is a prime example of a retailer that has become very serious about e-commerce. The company paid $3 billion last year for start-up Jet.com, installing founder Marc Lore as the head of its entire e-commerce operation. Since then, Wal-Mart has rolled out free two-day delivery, implemented discounts for customers willing to pick up their orders, and dramatically increased its online selection. Wal-Mart is also expanding its online grocery service, offering free grocery pick-up at hundreds of stores.

All of these moves have turbocharged Wal-Mart's e-commerce business. Domestic online sales surged 63% year over year during the first quarter, and 60% during the second quarter. And Wal-Mart is far from done. The company is testing various initiatives, like paying employees to deliver packages on their way home from work, and convenience stores geared toward grocery pick-up. In other words, Wal-Mart is becoming a lot more like Amazon, constantly trying new things in an effort to lower costs and increase convenience for its customers.

Given Amazon's dominance, simply selling stuff online isn't enough. Investors who want to bet on retail should stick to companies that have realized that becoming an omni-channel retailer, with a strong focus on e-commerce, is the only way to go.

If you're looking to profit from the retail apocalypse, investing in companies with a strong balance sheet and a serious focus on e-commerce will increase your odds of success.

Timothy Green owns shares of Best Buy. The Motley Fool owns shares of and recommends Amazon and Nike. The Motley Fool has a disclosure policy.