Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old April 22nd, 2012, 02:23 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Apr 2012
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default How do you do local development?

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

Advertisements
mongodroyd is offline  
Reply With Quote
sponsored links
Old April 22nd, 2012, 02:39 PM   #2 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,935
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 482 Times in 294 Posts
Default

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.
jonbonazza is offline  
Reply With Quote
Old April 23rd, 2012, 07:27 PM   #3 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,925
 
Device(s): GlassXE, MotoX, N5, N4, N7'12, GNex, N1, SGT10.1, Revue, Xoom, Eris, OG Droid
Carrier: TMO

Thanks: 4,608
Thanked 3,581 Times in 1,530 Posts
Default

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.
alostpacket is offline  
Reply With Quote
Old April 24th, 2012, 02:50 PM   #4 (permalink)
New Member
Thread Author (OP)
 
Join Date: Apr 2012
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by jonbonazza View Post
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.
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.
mongodroyd is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:19 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.