The curse of the green card: entrepreneurship for immigrants? 
white: Not a lawyer, so don't take my advises as is.  Incorporate in India, then transfer it all to US when you're ready.  Develop the code yourself, then have code acquired by your company, or prepare letter of intentions (that when you can do this legally, the code will be owned by the company for your stake increase).  And my understanding is that they don't care that much of you writing code for company either paid or free.  The government doesn't want everyone to create their own companies and get employed by themselves, getting legal status in US because of this.  Your case looks different though.