At first, it seemed like no matter what I did I’d just get the Enter IP Address or Hostname requester in my AIR app. So, to get rid of this dreaded requester once and for all follow my handy debugging AIR Android checklist!
It is currently a little fiddly to get debugging, but as Air for Android is still in beta, this will hopefully become more seamless in future. But in the current build, here’s a list of things to check:
- Check that your phone has debugging enabled in Settings-> Application Settings -> Development -> USB Debugging
- Make sure that USB storage on the phone is turned on. (These two settings are required to publish your apps onto the phone)
- Make sure both your computer and your device are connected to the same wi-fi network. Sounds obvious I know but sometimes my phone disconnects from the wi-fi.
- Within the Flash CS5 AIR Android Settings in the Deployment tab check the Device Debugging radio button.
- In the same settings, check Install Application on the connected Android device and uncheck Launch Application on the connected Android device.
- Enable INTERNET_PERMISSIONS in your app by adding the following to your app’s xml config file. This should be in the same folder and have the same name as your fla file, but with the suffix -app.xml. Open it in your text editor of choice and add the following XML :
<android> <manifestAdditions> <manifest> <data><![CDATA[ <uses-permission android:name="android.permission.INTERNET" /> ]]></data> </manifest> </manifestAdditions> </android>
Make sure you add this to the top of the XML, not the bottom! I put it between the <copyright> and the <initialWindow> definitions:
... <copyright></copyright> <android> <manifestAdditions> <manifest> <data><![CDATA[ <uses-permission android:name="android.permission.INTERNET" /> ]]></data> </manifest> </manifestAdditions> </android> <initialWindow> <content>MyApp.swf</content> ...
If you put it under the <initialWindow> definitions, the AIR Android extension seems to wipe it! It took me a while to work this one out, I expect they’ll fix it in the final build. I’ve also suggested that they set this permission by default if you’re publishing a debug build, it’d kinda make sense to me. 🙂
- Now you’re ready to publish the file, so hit Publish in the AIR Android Settings window. Your app will compile and get copied over to your device. But it won’t automatically run.
- Start remote debugging in Flash CS5: select the Debug -> Begin remote debug session -> Actionscript 3.0 menu item.
- And now run your app. With any luck, you should see the name of your swf in the debug output window.
You may still get the Enter IP Address or Hostname dialogue box but I must admit I only ever saw this if I didn’t set up the other options correctly. But if you do see it try typing the local IP address of your computer first, then the global one.
So! There you have it. Let me know how you get along and if there’s anything I missed.