Mapping a hostname to an IP address on Android - android

I know that I have to edit the /system/etc/hosts to map an IP address to a host name, but it seems that I can't edit the file. Is it because my android phone is not rooted?
Kindly advise. Thanks.

You can use the following guide and application to setup rules for specific domains.
Download (Daedalus) and open the application.
Click on the menu then click “Servers”
Click the add button and add the two google servers “8.8.8.8” and “8.8.4.4”, You can substitute these for your preferred DNS provider as well.
Activate these dns servers in the menu by clicking on “Settings”
Then select Google and Google 2 from the settings. Also activate Advance settings and select the two following options in the image below
Back to the menu now, Click on “Rules”.
Add a new rule for each development mode, Live, staging, dev. Filename is not crucial, just make something up.
Hit sync rule before leaving to make sure the file is downloaded.
Tap and activate the mode you wish to be in, You can activate more than one at a time so be careful as this will override one or the other.
In the menu go to home, and hit the “Activate” button.
Source: https://silocitylabs.com/post/2018/03/02/changing-dns-settings-for-android-development/

Try to remount using adb and edit the file

Why do you need to edit the hosts file?
You can simply add your host to a local DNS (e.g. the DNS announced by a local DHCP-Server in your Wifi-Network) or even in the real global DNS.

Related

Couldn't connect internet in xamarin android emulator -AVD_for_Nexus_One_by_Google

I have created simple listview apps using xamarin form and data are coming from webservices.
My current problem is , i couldnt connect internet my android emulator. Please anyone can guide how to do?
My Error image
Notes: My PC connected internet via LAN.
Connecting to the Internet from an Android emulator can be tricky.
One common issue is falling foul of a network proxy. If you have one on your network you need to configure it on the emulator.
Here is an article detailing Android emulator network settings.
You should check the connection settings of your emulator when you create one try creating one more emulator and revert us so we can help you create one.
The way i suggest you do it is use the emulators that visual studio provides check visual emulators in your respected search menu to find it .
One of the problems could be you do not have internet permissions which you can update in your manifest using this line:
<uses-permission android:name="android.permission.INTERNET" />
If this doesn't work follow the steps below :
1.Go to settings->Wireless & networks->mobile networks->Access Point Names.
2.Press menu button. an option menu will appear.
3.from the option menu select New APN.
4.Click on Name. provide name to apn say My APN.
5.Click on APN. Enter www.
6.Click on Proxy. enter your proxy server IP. you can get it from internet explorers internet options menu.
7.click on Port. enter port number in my case it was 8080. you can get it from internet explorers internet options menu.
8.Click on User-name. provide user-name in format domain\user-name. generally it is your systems login.
9.Click on password. provide your systems password.
10.press menu button again. an option menu will appear.
11.press save. try n run your browser. hope its work for you it worked for me. good luck.

SUP android native app

Is it possible to have user put in connection properties like ip address in the app to connect to Sybase. I need to find out for a test to connect to our DR Site which has a different IP address. (So user uses production system and something happens and need to switch to the DR Site to continue working.)
Thanks
Louis
I don't know much about SUP, but it seems the IP address of the server is in the generated code (Activity classes), you cam edit this code to get the IP from somewhere (e.g. the application settings).
If you don't have access to the source code of the application and this is just for a test you can configure your android device to use a proxy (How to change proxy settings in Android (especially in Chrome)) and then make a simple proxy that redirects connections to another host (such as those described in seriously simple python HTTP proxy?).

Can't run IBM worklight app in real device android

I build a worklight application. create android app and test this application with local machine , its working fine with emulator.but when i try to test this application with android tablet it through error "The Application failed connecting to the service".
I try to find application-descriptor.xml and fix localhost to 192.168.1.1:8080
my ip local machine,but it not working.In my tablet I can't to go to 192.168.1.1:8080/console/index.html
Can anybody help me regarding this issue. how can i fix this one in my worklight android application and run it on my android tablet
Some things to check:
- Are your tablet and your worklight development machine on the same wireless network? (they need to be!)
- Does your computer have a firewall on it which may need configuring to let the traffic through. As a test you could briefly disable the firewall and see if you then have access (subject to disclaimer of the risk involved in disabling the firewall). A test without disabling the firewall would be to try accessing 192.168.1.1:8080 from another desktop/laptop machine on that same subnet.
Check ip in local machine ipconfig ( field Adaptador de Ethernet )
Set this IP in field host name configuration server.
Rebuild
The other test is to check the direction in other machine, in the same network.
In a command window, run ipconfig and copy the IPv4 address. This is the IP address you need to place as the value for worklightServerRootURL in the file application-descriptor.xml.
The IP address you are usingnow does not look to me like the correct (public) IP address that you need to use. Try my above suggestion.
How about adding "192.168.181.1:8080" in application-descriptor.xml?
I would suggest the following debugging steps:
a) Go to your device browser and browse to http:
//xx.xx.xx.xx:8080/console
-> If this doesn't work, you have an obvious ip address issue. Then you have to figure out why, maybe you have a Symantec thingy that blocks any incoming traffic to your desktop - which they do. You should do an explicit allow.
b) If a) works, then you need to check in your code to make sure your app does try to connect to the server at startup. Or else the app will only try to connect when it calls adapter.
Now, go to your code. open the initOptions.js file. I typically, would set connectOnStartup to true, but also enable the onConnectionFailure so that it runs offline when there is no connection.
var wlInitOptions = {
// # Should application automatically attempt to connect to Worklight Server on application start up
// # The default value is true, we are overriding it to false here.
connectOnStartup : true,
// # The callback function to invoke in case application fails to connect to Worklight Server
onConnectionFailure: function (){wlCommonInit();},
// # Worklight server connection timeout
timeout: 2000,
};
3) Make sure you have the right URL in the application-descriptor.xml
<worklightServerRootURL>http://xx.xx.xx.xx:8080
</worklightServerRootURL>
If you are using the consumer edition (the real purchased WL), your URL would be.
<worklightServerRootURL>http://xx.xx.xx.xx:9080/worklight
</worklightServerRootURL>
(Note no space in between those URL - it's just this website putting a space there when there is a line break)
Redeploy your code to the WL server and create a new APK file. Update your device with the new APK file.
4) Do a test with the console again, you should see the console. Click on the Preview app link, it should work.
5) Now that you have updated your code on the server and the APK file. Open it up again on the device.
Do you still see the error message?
If things still not work.
6) Go to the app setting, since you have enable offline mode, it would allow you to access the App settings (it's the 4th button in Android) Go to Worklight Settings. Select Server Address -> Add the worklight URL to the Server URL. When you go back to the app, this will automatically reload the content from your WL server.

Android AVD emulator accessing Internet from behind firewall

Is it possible to access the Internet from an Android 4.1 AVD emulator, running on a PC behind a firewall?
If I click on the Browser icon, I get an error saying "Webpage not available. Make sure you have a data connection."
If I click on the Maps icon, I get an error saying "Network failure. This application requires a working data connection."
If I try to add an Email account, I get an error saying "Couldn't open connection to server."
I have added -dns-server 10.xxx.xx.31,10.xxx.xx.32 -http-proxy http://10.xxx.xx.201:8080 (with correct IP addresses!) to emulator.exe command-line, but this does not seem to make any difference?
I can see the "3G" symbol next to a triangle at the top of the screen, and I can toggle it using [F8] key, but this does not seem to make any difference either.
Thanks for your help,
Best regards,
James
I have managed to RESOLVE this problem using the instructions below :-
Inside ADK emulator, goto Settings icon -> Wireless & Networks ->
Mobile networks -> Access Point Names
Press [F2] and select "New APN"
Name = James
APN = www
Proxy = 10.xxx.xx.201
Port = 8080
Username = xxxxxxxx
Password = xxxxxxxx
Press [F2] and select "Save"
Click "James" to set as default APN
Now goto Browser and you should be able to see homepage :)

Cannot add a google account to android emulator

I am having a problem connecting my android emulator to gmail. I cannot add my gmail account even though I can browse the web.
I go to the Accounts and Sync/add account/google/sign in, and put in my gmail address and password and then get the following message after a long wait -
"Can't establish a reliable data connection to the server"
I am going through a company proxy so I suspect this may be the problem. This also happens if I try the create new option.
Does anybody know what port needs to be open for this activity to occur, if indeed this is the problem?
Or if anybody has any alternative explanations I would be keen to hear them, as I am stumped.
I am running Android 2.2 with the google apis.
THE FOLLOWING SOLUTION DOES NOT WORK ANYMORE SINCE API 16 OR 17 (not sure of the number)
Click Add Account, EMail.
Enter your gmail address and password
Click on Manual Setup
Choose Exchange
For the Domain\Username enter \yourEmail#gmail.com (don't forget the backslash at start, and the #gmail.com at the end)
Server: m.google.com (not gmail.com)
Check use SSL (should be already checked)
Click Next, next, next
That's it !

Categories

Resources