Modify the hosts file and out of memory solutions at android

Because the android emulator host file can not be modified, making it impossible to call the network service by using a domain name http method, so a method from a large number of online reprint of this approach:

    1.128 cranking simulator by emulator -avd avdName -partition-size

    2. Command to gain root privileges via adb root and adb remount.

    3. By adb pull / system / etc / hosts hosts file transfer command to the PC, manually modify the hosts, and the hosts file by adb push back push again.

     This problem is because linux line breaks and line breaks window of inconsistency caused most of the online method is to use ultraedit such as your editor, but I still can not modify the copy to the editor. Posted in malbers replied, using the echo command, you can directly through the command will need to modify the contents added to the hosts file, tried it, it really feasible.

     First, type adb shell command (the new version of the sdk adb commands are transferred to the platform-tools directory), and then 192.168.0.246 echo  www.aaa.com >> / System / etc / hosts after typing the above command, then use cat / system / etc / hosts file hosts modify the view, the hosts found it really has been modified, but the problem is still not wrap, seemingly only be recognized later for the trip,

Therefore, use the echo command again joined the line breaks, the problem is solved. Specific operation is as follows:

     A few steps in front of the same, but does not need to pull the hosts file on your computer, if you have modified but in vain, you can pull out and restored to its original state, do not have any line breaks, and replace

The simulator has been modified hosts, it back to its original state. That is only 127.0.0.1 localhost.

    Then enter adb shell, using echo -e \\ n >> / system / etc / hosts added newline hosts file.

    Use echo 192.168.0.246 www.aaa.com >> / system / etc / hosts again.

    This complete solution newline problem. Knock www.aaa.com again in the browser, the page also appeared familiar.

 

Specific steps are as follows

1, to obtain root privileges: adb root

 

2, set / system read-write: adb remount

 

3. Copy the hosts file to the PC: adb pull / system / etc / hosts <file name on a PC>

 

4, modify the machine files on PC

 

5. Copy the files on the PC to the phone: adb push <file name on a PC> / system / etc / hosts

 

But in the fifth step, some people will be reported out of memory error

 

This is because the command line to start directly, but did not add a parameter caused, so use the following command to start on the line

$emulator –avd youravdname –partition-size 128

From (the wall may be)

http://www.cuteandroid.com/tips-for-android-developer-failed-to-copy-file-to-system

Reproduced in: https: //my.oschina.net/zhepama/blog/265028

Guess you like

Origin blog.csdn.net/weixin_34080571/article/details/91927357