Submitted by admin on

If you are developing on your localhost and you need to access your dev website in your Android app, there is a few steps to achieve this. A use case example is Cordova (Phonegap) based platform DrupalGap which connects to a Drupal website to fetch data.
First we need to define a port. Add this line to /etc/apache2/ports.conf:
listen 55555
Then we need to add the port to apache’s virtual host. Edit /etc/apache2/sites-available/YourSite.dev.conf file and copy all <VirtualHost *:80> … </VirtualHost> section and paste it in the button of the file and change the first line to:
<VirtualHost *:55555>
Then we need to restart apache by executing this command in terminal:
sudo services apache2 restart
Now our dev website will be available on http://localhost:55555
For Android emulator we will need to use http://10.0.2.2:55555 to access the website. So in DrupalGap application, in YourApp/www/app/settings.js set Drupal.settings.site_path to http://10.0.2.2:55555 and the dev website will be available for DrupalGap.
Enjoy!