You will get deported and effectively be permanently banned if you receive income from any other source besides your H-1B / L-1 / other-visa sponsoring company/employer. Income from all other sources are prohibited while you are on a visa. With a green card or U.S. citizenship, you have the freedom to sell apps, write books, etc.

Companies are required to report any income you earn while you are in the US. If you make money selling apps, Google/Apple is required to tell the U.S. government about the money you make on the App Store income (primarily for tax purposes).[1] The tax people (the IRS, Income Revenue Service) share income data with the immigration agency. The immigration agency checks to make sure you only got money from the company your visa allows you to work for. If the immigration agency finds out you have income from other sources (app store), they will deport you, and you will effectively be banned. See: http://www.murthy.com/2014/01/28/home-based-businesses-inadv...

If you look at the link above, you'll see a lot of people have inadvertently screwed over by having non-authorized income. An extreme example from the link above are multi-level marketing companies. For example, you recommend your friend that he/she buys some product. Your friend buys it, and for the referral, the company gives you a tiny amount of money (e.g. $5) You could get deported and banned because of this. Because it is considered income, and all income not from your job associated with your visa is completely prohibited.

----

Now you might be wondering if you can set up your company and receive income from the App Store in India, and have it deposited to your Indian bank account. You might be thinking that if you do that, your income likely won't be reported to the US government, and you won't get caught and get deported.

The problem with that is that by having un-reported income in India (from the App Store) you are breaking two sets of laws: (1) tax laws, (2) immigration laws.

Firstly, if you live in the U.S., you have to pay taxes (~35%) on your total worldwide income -- income that you make in every country. Even on the interest you receive in a bank account in a foreign country. If you do not report your non-U.S. income, you break tax law. The punishment for breaking tax laws is severe. In addition to being deported and banned, they can take money out of your bank account, seize your property (your house, your car, etc) to pay for the unpaid taxes + the severe fines for hiding and not paying taxes.

Secondly, U.S. immigration law generally prohibits H-1B, L-1 and other visa holders from doing any kind of productive work outside their H-1B/other-visa job. Even repairing your own house by yourself, if it involves a lot of work, is illegal for a visa holder. You have to hire a U.S. worker to repair your house. Foreign income for remote work is prohibited. Working on your own app and making money selling it is prohibited.

----

[1] I don't know if you are in the U.S. -- so just to clarify: everyone in the U.S. who has permission to work (citizens, LPRs, H-1B/L-1/etc visa holders) is issued a Social Security Number ("SSN"). This number is used to report any income you earn to the government. You have to provide this number to receive income from any company in the US. If you try to set up a U.S. Google App Store account, they will ask for your SSN. Your SSN is used to report your income to the government, and as a general universal personal identification number.