You’ve probably heard this before: Hardware is hard. How hard? According to CB Insights, 97 percent of hardware startups will fail or become “zombies” — and it’s little wonder when even behemoths like Apple encounter regular difficulties bringing their products to market on time.

Angel investor Benjamin Joffe wrote an article discussing why such a small minority of hardware startups make the cut and the rest don’t. When your startup chooses a manufacturer, he says, that factory “is your PARTNER, your BANK, your INVESTOR. [Your product is] a new dish, you’re the chef. Be in the kitchen.”

This is the single greatest piece of advice a hardware startup can receive, and any that hope to get a product to market on time can’t neglect it.

Unfortunately, finding a factory and establishing a meaningful relationship is much easier said than done. Especially if your manufacturer is in China.

Here’s what you need to know.

Do everything you can do yourself

When you’re bringing a hardware product to market, even the very small stuff is complicated and expensive, especially if you’re not a do-it-yourself kind of person.

But let’s hope for the moment that you are.

Do everything you can by yourself. Get as far as possible before you start spending money. When you reach the end of your own skill set, find a local genius who can tell you what components you need or what parts must be produced to move things forward.

In the best case scenario, this person becomes your partner. In reality this person is likely going to be either someone you pay a lot of money, like a consultant, or a friend who is not a genius but who is willing to help you out.

Then you will pay someone else a lot of money to do the first designs and blueprints, and you will start by talking to factories in the U.S. or Europe because you want to support local industry and because that’s within your comfort zone. You’ll get those bids back and feel like they are way too expensive.

That’s when you’ll realize you have to take production to China.

Pack your bags and head to the East

You’ll fly to Hong Kong and meet people you found online. You’ll also look at Alibaba to find factories, and you’ll get 1,000 offers from different vendors promising you great prices and a final product without really understanding what it is you’re looking for. You’ll also have agents back home helping you. You’ll visit five or 10 factories in Shenzhen or Shanghai, and you’ll get very drunk with each of the factory owners. (As I learned the hard way, little business gets done in China without copious amounts of alcohol involved; in fact, the drinking is a much more important part of Chinese business culture than signing papers.)

You’ll spend a few weeks there and get a good feeling for someone. You’ll make an agreement — likely the agreement that most benefits you — and that will be the first major mistake you make. You’ll give them a down payment, and then you’ll fly home. That will be your second mistake.

The path to a failed launch is paved with bad prototypes

The biggest killer of a hardware project is when you have found that factory, production has started, you get some good indications over email or Skype, and then you finally get your prototypes. And they just suck. There’s absolutely nothing you can do with them, and they’re nothing like what you were promised.

Most entrepreneurs coming from the West to China think that if you sign an agreement, you have the specifications, and the first money is transferred, you’ve sort of won the race. But when you get your first product from the factory and realize it’s not at all what you had in mind, the factory just won’t answer — in my experience — to the fact that you’ve been paying them or that you have a contract.

In the U.S., paper matters. In China, for all intents and purposes, you don’t have any protection. Especially if you’re a foreigner.

You need your factory partner to five a f*ck

The only thing that’s going to get you a good prototype — and a good product — is to establish a meaningful relationship with the owner of the factory.

When the first prototype flops, you’ll switch factories, and you’ll know a bit more. Then you’ll switch factories again. At that third factory, you’ll get a prototype that actually works. You’re about two years in at this point, but that third factory is probably a good factory, and that factory is going to be a partner for a few years or until you scale out of their facilities.

Plan to be on site for many, many weeks. Work with the manager, get involved, and talk to the engineers. Have real talks with the factory owner. Spend time with them. This will involve going out for dinners and, again, drinking a lot.

But most importantly, you’ve got to treat them as business partners who are not just producing stuff for you. You’ve got to listen to each other; the idea is to find ways to make the future profitable for both parties.

So, now you’re well on your way. But there are still a few things to be aware of.

Understand that you can never really just pack up and go home

You have a manufacturing partner, and you’ve learned a lot. But there are at least three factories in China that know what you’re doing and have all of your design specifications. By the time your product comes out, there may be a lot of copies already on the market.

But let’s set that aside for the moment.

You’ll need someone on the ground to approve prototypes so you don’t waste time and money shipping them back and forth to your headquarters. And you’ll need this person there once production is in full swing to continue doing quality control and to do triage when things go wrong. For example, when the software isn’t functioning properly because the manager in charge of processing the chips has been watching too much internet porn and the computer you provided is teeming with viruses. Or 20 percent of your chips are malfunctioning because the factory that is mounting the components onto the PCB is overheating the lead.

It’s going to be complicated. Plan accordingly.

Getting a hardware product to market on schedule requires navigating a complicated and fraught manufacturing process. The little things will cause you the biggest headaches and setbacks, and the solutions will be annoyingly simple and solved by finding the right local manager on the top floor of a desolate concrete building chain-smoking cigarettes in the near dark, watching too much internet porn.

But when you do find this individual and work out a solution, you will succeed in getting a product that works. The key is realizing that you can’t bend China to your will.

It’s your job to learn the ropes, find allies, be patient and tenacious — and plan accordingly.

Felix von Heland is founder and CEO of smart toys company WRLDS. He and his co-founder have collectively spent nearly 10 years transacting business in China.