This is a great question! I've been an entrepreneur and small business owner for 20+ years and have started small businesses in 3 states that grew into nice income streams for me. I've lived off these businesses for 20+ years, so I know it can be done!
First let me start by saying that the rules, regulations, requirements and laws for operating a business (small or large) legally, for the most part, are local laws and regulations. Depending on what your business does, you may have some federal rules to follow, but for the most part, it will be your locality (state, county, city) that determines what you'll have to do to comply and be "legal". Also, though it might be better in some cases to incorporate (and even required in some circumstances), you don't always have to. There are many small businesses (think landscapers, housekeepers, babysitters, etc.) that get income from their "business operations" and do so as "individuals". Of course, everyone has to pay taxes - so as long as you property record your income (and expenses) and properly file your tax returns every year, you are "income tax legal".
I won't try to answer the income tax question here, though, as that can be a big question. Also, though you certainly can start a business on your own without hiring lawyers or other professionals (more on that below), when it comes to taxes, I definitely recommend you indeed plan to hire a tax professional (even if it's something like H&R Block or Jackson Hewitt, etc). In some cities, there might even be "free" tax preparation services by certain organizations that want to help the community and these are often available even to small businesses. In general, income taxes can be complicated and the rules are always changing. I've found that most small business owners that try to file their own taxes generally end up paying a lot more taxes than they're required to, in essence, they are overpaying! Running a business (and making a profit) can be hard enough, so on to of that, you don't need to be paying more than you are required to!
Also, I am going to assume that since it sounds like it would be a business of one (you), that you won't have a Payroll. That is another area that can be complicated for sure.
Ok, with those generics out of the way, let me tackle your questions related to starting and operating a business, since you have the "idea for your business" pretty figured out.
Will you have to pay any substantial amount of money to attorneys or advisors or accountants or to register with the government?
Not necessarily. Since the rules for operating a business legally vary by your operating location (where you will be providing the service or performing your work), you can certainly research this on your own. It might take a little time, but it's doable if you stick with it.
Some resources: The state of Florida (where I live) has an excellent page at: http://www.myflorida.com/taxonomy/business/starting%20a%20business%20in%20florida/
You might not be in Florida, but almost every state will have something similar.
What all do I need to do to remain on the right side of the law and the smart side of business?
All of the answers above still apply to this question, but here are a few more items to consider:
You will want to keep good records of all expenses directly related to the business. If you license some content (stock images) for example, you'll want to document receipts. These are easy usually as you know "directly". If you subscribe to the Apple Developer program (which you'll need to if you intend to sell Apps in the Apple App Stores), the subscription is an expense against your business income, etc.
You will want to keep good records of indirect costs. These are not so easy to "figure out" (and where a good accountant will help you when this becomes significant) but these are important and a lot of business owners hurt themselves by not considering these. What do I mean? Well, you need an "office" in order to produce your work, right? You might need a computer, a phone, internet, electricity, heat, etc. all of which allow you to create a "working environment" that allows you to "produce your product". The IRS (and state tax authorities) all provide ways for you to quantify these and "count them" as legitimate business expenses. No, you can't use 100% of your electric bill (since your office might be inside your home, and the entire bill is not "just" for your business) but you are certainly entitled to some part of that bill to count as a business expense. Again, I don't want to get too far down the INCOME TAX rabbit hole, but you still need to keep track of what you spend!
You must keep good record of ALL your income. This is especially important when you have money coming in from various sources (a payroll, gifts from friends, business income from clients and/or the App Stores, etc.) Do not just assume that copies of your bank deposits tell the whole story. Bank statements might tell you the amount and date of a deposit, but you don't really know "where" that money came from unless you are tracking it!
The good news is that the above record keeping can be quite easy with something like Quicken or QuickBooks (or many many other such popular programs.)
You will want to ensure you have the needed licenses (not necessarily required at all for a lot of small businesses, especially home based businesses.)
Depending on your business activity, you might want to consider business liability insurance. Again, this will depend on your clients and/or other business entities you'll be dealing with. Some might require you to have some insurance.
Will be efforts even be considered a business initially until some amount of money actually starts coming in?
This might be a legal / accountant question as to the very specific answer from the POV of the law and taxing authorities. However, consider that not all businesses make any money at all, for a long time, and they definitely "are a business". For instance, Twitter was losing money for a long time (years) and no one would argue they were not a business.
Again, deferring to the attorneys/cpas here for the legal answer, the practical answer is that you're performing "some" business activity when you start creating a product and working hard to make it happen! I would consider "acting as" a business regardless!
What things do I need to do up-front and what things can I defer to later, especially in light of the fact that it might be several months to a couple years before any substantial income starts coming in?
This question's answer could be quite long. There are potentially many items you can defer.
However, one I can say is that you might consider deferring incorporation. An individual can perform a business activity and draw income from it legally in a lot of situations. (For tax purposes, this is sometimes referred to as "Schedule-C" income.) I'm not saying incorporation is a bad thing (it can shield you from a lot of issues), but I am saying that it's not necessary on day 1 for a lot of small businesses. Having said that, this too can be easy to do on your own. Many companies offer services so you can incorporate for a few hundred dollars. If you do incorporate, as a small business of one person, I would definitely consider a tax concept called an "S-Corp" to avoid paying double taxes.) But here too, we've gone down the tax rabbit hole again. :-)