5,601,223 Members 55,333 Now Online
XDA Developers Android and Mobile Development Forum

[Q] lost etc/hosts file

Tip us?
 
Bdvs
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 3
Join Date: Sep 2012
Phone [Q] lost etc/hosts file

hello everyone
I have a t-mobile note 2 rooted and i was having problems with my play store and deleted my hosts file by mistake i tried making a new one with root explorer but it fails is there anything els that i can do to get it back when i reset my phone the play store is gone and i don't know what to do any help would be great.
 
ciphercodes
Old
(Last edited by ciphercodes; 9th January 2014 at 12:26 AM.)
#2  
Senior Member
Thanks Meter 173
Posts: 390
Join Date: Oct 2012
Quote:
Originally Posted by Bdvs View Post
hello everyone
I have a t-mobile note 2 rooted and i was having problems with my play store and deleted my hosts file by mistake i tried making a new one with root explorer but it fails is there anything els that i can do to get it back when i reset my phone the play store is gone and i don't know what to do any help would be great.
Do you have access to a system with adb or heimdall ?
If not
You can create a new file(text) named hosts under /etc/system/ with the following line
127.0.0.0 localhost
You can set the permissions of this file to 0644 via root explorer or using Terminal Emulator:
----
cd /system/etc
chmod 644 hosts
---
Never used root explorer but there has to be a GUI option somewhere in it.
You will have to mount the /system to read-write mode in root explorer in order to make any changes.
Once you have created the file, reboot the phone and see if it works, if not then manually delete all files under /system/data/dalvick-cache.
Be careful before deleting any file, make sure you browse to /system/data/-dalvick-cache directory and select all files and then delete them.
 
Bdvs
Old
#3  
Junior Member - OP
Thanks Meter 0
Posts: 3
Join Date: Sep 2012
Quote:
Originally Posted by ciphercodes View Post
Do you have access to a system with adb or heimdall ?
If not
You can create a new file(text) named hosts under /etc/system/ with the following line
127.0.0.0 localhost
You can set the permissions of this file to 0644 via root explorer or using Terminal Emulator:
----
cd /system/etc
chmod 644 hosts
---
Never used root explorer but there has to be a GUI option somewhere in it.
You will have to mount the /system to read-write mode in root explorer in order to make any changes.
Once you have created the file, reboot the phone and see if it works, if not then manually delete all files under /system/data/dalvick-cache.
Be careful before deleting any file, make sure you browse to /system/data/-dalvick-cache directory and select all files and then delete them.
I have adb access how would i do it with adb
root explorer wont let me make a text file
 
ciphercodes
Old
#4  
Senior Member
Thanks Meter 173
Posts: 390
Join Date: Oct 2012
Quote:
Originally Posted by Bdvs View Post
I have adb access how would i do it with adb
root explorer wont let me make a text file
1) Using text editor create a text file named "hosts" with the following contents:
---
127.0.0.1 localhost
---
If you are on windows make sure you remove the file extension.
2) Connect phone via USB and open command prompt or shell. Make sure USB Debugging is checked under developers options.
3) Check if adb detects your device by typing: adb devices , you should see your device listed, if not please check if your phone has correct USB drivers.
4) Now push the file you created to your phone with this command : adb push /path/to/file/hosts /sdcard/hosts
example: adb push C:\tmp\hosts /sdcard/hosts
5) Now log in to your phone by typing adb shell
6) Switch to super user by typing: su , grant permissions when asked by SuperSU.
7) Mount system in read-write mode by typing: mount -o remount,rw -t yaffsw /dev/block/mtdblk3 /system
8) Move the hosts file to /system/etc by typing: mv /sdcard/hosts /system/etc
9) Browse to /system/etc by typing: cd /system/etc
10) Change file owner and group by typing: chown root:root hosts
11) Change file permissions by typing: chmod 644 hosts
12) Mount system back to read only by typing: mount -o remount,ro -t yaffsw /dev/block/mtdblk3 /system
13) Delete dalvik cache by browsing to cd /data/dalvik-cache and then type rm -f *.dex
14) type exit two times to exit.
15) Reboot phone and it should work.

I believe there might be an easy way or an apk which does this but I haven't tried it.
 
Bdvs
Old
#5  
Junior Member - OP
Thanks Meter 0
Posts: 3
Join Date: Sep 2012
Prompt play store

Quote:
Originally Posted by ciphercodes View Post
1) Using text editor create a text file named "hosts" with the following contents:
---
127.0.0.1 localhost
---
If you are on windows make sure you remove the file extension.
2) Connect phone via USB and open command prompt or shell. Make sure USB Debugging is checked under developers options.
3) Check if adb detects your device by typing: adb devices , you should see your device listed, if not please check if your phone has correct USB drivers.
4) Now push the file you created to your phone with this command : adb push /path/to/file/hosts /sdcard/hosts
example: adb push C:\tmp\hosts /sdcard/hosts
5) Now log in to your phone by typing adb shell
6) Switch to super user by typing: su , grant permissions when asked by SuperSU.
7) Mount system in read-write mode by typing: mount -o remount,rw -t yaffsw /dev/block/mtdblk3 /system
8) Move the hosts file to /system/etc by typing: mv /sdcard/hosts /system/etc
9) Browse to /system/etc by typing: cd /system/etc
10) Change file owner and group by typing: chown root:root hosts
11) Change file permissions by typing: chmod 644 hosts
12) Mount system back to read only by typing: mount -o remount,ro -t yaffsw /dev/block/mtdblk3 /system
13) Delete dalvik cache by browsing to cd /data/dalvik-cache and then type rm -f *.dex
14) type exit two times to exit.
15) Reboot phone and it should work.

I believe there might be an easy way or an apk which does this but I haven't tried it.
Thanks for all your help i got the hosts file in to system/etc folder but my play store is still not working i get a pop up that play store has stop working so i cleared cache for play store, play services and google framework and its still not working
any ideas thanks again
 
ciphercodes
Old
(Last edited by ciphercodes; 11th January 2014 at 09:28 PM.)
#6  
Senior Member
Thanks Meter 173
Posts: 390
Join Date: Oct 2012
Did you delete dalvik cache ?

Sent from my SGH-T889 using xda app-developers app
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Decompile, Edit, and Recompile in One Tool with APK Studio

If you’ve ever modified precompiled applications, you have undoubtedly spent … more

TasGear: A Tasker Extension for the Samsung Galaxy Gear

With wearable technology taking center stage this year, one can only expect more … more

Intelligently Place Contacts on Your Home Screen with CallWho Widget

There are plenty of ways to get your contacts to show up on your … more