The android simulator cannot access the Internet ~~

Source: Internet
Author: User

Recently, I started to contact Android. After the simulator is installed, I cannot access the Internet. The solution is as follows:

Method 1

First, configure the adroid environment variable in Windows (win7 is used as an example)

1. Right-click the desktop-my computer-advanced system settings

2. Advanced -- environment variable -- System variable -- path

3. Add android
The SDK directory is in the path of the system variable,

Note: Add Android-SDK-Windows \ tools to System Path

If F: \ Android-SDK-Windows \ platform-tools are available, add them to the system path,

Note: The latest Android SDK is installed. The emulator command is generally in the tools directory, and the ADB command is moved to the platform-tools directory.

 

Start the simulator.

1. CMD (CTRL + R, start the command prompt form)

2. emulator-AVD avd2.1 (start the simulator. avd2.1 indicates the name of the simulator Where Android is installed)

3. CMD (CTRL + R, and then start the command prompt form)

Then, write the network connection proxy settings to the configuration database.

1. ADB shell (enter the Linux System of the simulator. This command is valid only after the simulator is started successfully)

Assume that your Internet proxy IP address is 10.10.26.252: 1080.

2. Write data to the database and update system settings

Sqlite3/data/COM. android. providers. settings/databases/settings. DB "insert into system values (99, 'HTTP _ proxy', '10. 10.26.252: 1080 ')"

3. query the database to see if the system settings have been successfully changed:

Sqlite3/data/COM. Android. providers. Settings/databases/settings. DB "select * from System"

(SQLite is a micro-database used by the Android mobile system. You can understand it as a commonly used database such as access, MySQL, and SQL server .)

4. Restart the simulator and use browser to access the Internet.

Finally, to delete a database, run the following command:

Sqlite3/data/COM. Android. providers. Settings/databases/settings. DB "delete from system where _ id = 99"

========================================================== ========================================================

Method 2

1. Refer to method 1 to set system variables and start the simulator.

2. GoSettings-> wireless controls-> mobile networks-> Access Point names
3. Set the following parameters:
-Proxy: your proxy address
-Port: your proxy Port
-UserName: your username if needed, or <not set>

Password: Your password if needed, or <not set>

4. Set DNS parameters:

The default address of the android simulator is 10.0.2.3, and the default DNS is 10.0.2.3. For people who study Android online at home (like me), the IP address of the computer is 192.168.1.100, not in the same CIDR block. Therefore, the computer can access the Internet, but the simulator cannot access the Internet. In fact, the setting method is very simple. You only need to set the default DNS of the simulator to the DNS address of the computer.

Step 1: ADB shell (enter the Linux System of the simulator)

Step 2: getprop (getprop lists the current attributes of the system)

Step 3: Obtain the DNS address of the simulator.

In the result, we can see:

[Net. dns1]: [10.0.2.3]
[Net. dns2]: [10.0.2.4]
[Net. dns3]: [10.0.2.5]
[Net. dns4]: [10.0.2.6]

Step 4: Change DNS to our own DNS

Setprop net. dns1 192.168.1.1 or setprop net. dns1 192.168.0.1

Note: General TP-LINK and D-LINK wireless DNS are 192.168.1.1, some companies wired DNS default 192.168.0.1;

If the above two DNS servers are not easy to use, use the ipconfig/All (Windows System) or ifconfig-A (Linux/Unix System) command to confirm.

If you use the browser of the simulator again, you will find that you can access the Internet.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.