How do you do local development?


Last Updated: 2012-04-24 19:50:35
  1. mongodroyd

    mongodroyd New Member

    Hello,

    I'm an old-time web developer but new to mobile development. I'm trying to figure out how to go about doing local development and testing for android tablet devices. My usual development scenario involves a local instance of Apache with virtual hosts. For example, I'll have numerous sites under local development:

    local.mysite1.com
    local.myfancysite.com
    local.whateversite.com

    I resolve these sites locally with /etc/hosts pointing to 127.0.0.1

    Here's my problem. Once I compile and debug the android app on the tablet device, it needs to phone home to the web server. However, I don't seem to be allowed to edit the /etc/hosts on the Android device. Wtf?

    How do you guys deal with this problem? I'd prefer to do testing on the device itself rather than an emulator. Any suggestions?

    Here are the only things I can think of and I don't like either:

    1) Root the tablet (this seems like a pain)
    2) Push all local coding changes to a test server for every debug session and have the tablet communicate with the test server

    I don't like the second option because with multiple developers touching a test server, it is certain that we will be stepping on each others' toes and intermittently and erratically breaking code. Plus it's not efficient, and I don't like committing unnecessary changes.

    How do you guys do local development efficiently?

    Thanks

    Advertisement
  2. jonbonazza

    jonbonazza Well-Known Member

    Google provides many tools for testing applications from inside of the Eclipse IDE. You can either open an emulator (very slow and limited functionality, but provides quick testing) or test directly on your device by tethering it via USB.

    For more information, look here:
    Debugging | Android Developers


    Also, the Android Developers Page will be your most useful reference as an Android dev, so I recommend looking around.
  3. alostpacket

    alostpacket Over Macho Grande? VIP Member

    Assuming the phone is on wifi...

    Sounds like you might want something like wireshark and/or to configure your WiFi to redirect specific http calls from the phone back to a local server.

    i.e. port forward from your phone's IP back to your computer's IP.

    I would think this also could be done by setting up your computer as the WiFi Access Point.
  4. mongodroyd

    mongodroyd New Member

    Right, I'm talking about the USB tethering method. The problem is, the android device doesn't know how to resolve back to my local testing environment. This is more of a nameserver issue. So I'm curious what techniques you guys/gals are using. Do most of you use an emulator? The emulator seems brutally slow and clunky on OS X.

    Update: I ended up rooting the device and now it's not an issue. I can edit my /etc/hosts file as needed, although I had to mount the /system drive as read/write since it is a read only file system.

    Here's what I did in case anyone else needs to edit or update their /etc/hosts file in android (after rooting it). First root the device then get an SSH daemon up and running on it. Log into it then:

    1) Find out how your /system directory is mounted:
    #df

    You should see something like:
    Filesystem 1K-blocks Used Available Use% Mounted on
    tmpfs 372612 32 372580 0% /dev
    tmpfs 372612 0 372612 0% /mnt/asec
    tmpfs 372612 0 372612 0% /mnt/obb
    /dev/block/mmcblk0p3 604736 491228 113508 81% /system
    /dev/block/mmcblk0p8 13194624 186608 13008016 1% /data
    /dev/block/mmcblk0p4 1214016 32844 1181172 3% /cache
    /dev/block/mmcblk0p6 30224 4136 26088 14% /system/vendor
    /dev/fuse 13194624 186608 13008016 1% /mnt/sdcard
    /dev/block/vold/179:33
    3862528 558720 3303808 14% /mnt/external_sd



    Mine above has /system mounted as "/dev/block/mmcblk0p3 /system"

    2) Remount the drive as readable/writable:
    #mount -o rw,remount -t yaffs2 /dev/block/mmcblk0p3 /system

    Just make sure the last part of the path matches your system.

    3) Now you can edit /etc/hosts:
    #vi /etc/hosts

    Rooting seems the way to go I guess.

Share This Page