Editing the host file - new entry has no effect - Android Q&A, Help & Troubleshooting

Hi folks,
I'm developing a new version of a live website in WordPress with domain mapping so that the URL is like-for-like with the live site. On a PC, I just change my host file to point to the WordPress IP address.
I now need to test the WordPress site on a phone.
I have an old HTC Desire with Android 2.3.4 (rooted) that I'm trying to use, so need to add the WordPress IP to the host file.
Using ADB, I've managed to retrieve the hosts file from the phone, edit it and place it back on the phone using:
Code:
adb remount
adb pull /system/etc/hosts /hosts
[edited host file]
adb push /hosts /system/etc/hosts
To double-check that the hosts file really has updated, I've deleted hosts from my computer, then pulled it again from my phone. Opening it up in Notepad++ I can see that it does contain the new entry.
The strange thing is, if I open a web browser to the url I'm trying to map to the WordPress IP address, it still goes to the live website, not the WordPress server. I've verified this using PingTools - the returned IP address is that of the live server.
I'm guessing I need to flush the DNS but it seems the only way to do this is a reboot. But upon reboot, the new entry in the hosts file is gone and we're back to only "127.0.0.1 localhost", so I'm now at a loss.
Any thoughts on where to go from here?
EDIT
After doing the above, installing and loading 'Hosts tool' from Google Play, sometimes the new host entry is there, but most of the time the host file disappears from the phone completely! Looking through ASTRO file manager, it confirms the host file has vanished. Rebooting the phone gets it back, but then we're then back to only "127.0.0.1 localhost" in the host file

I've fixed the problem. For some reason, there needs to be a line feed after the last entry in the host file.
To do this, open the host file in Notepad++ and go the view menu > Show symbol > Show characters. Copy the LF character at the end of "127.0.0.1 localhost" and paste it to the end of each line if it doesn't already have the LF character at the end.
Android refreshes its DNS every 10 minutes, so it's then just a matter of waiting.

Related

[Q] Copy file from sdcard to Samba network directory

Hi, We have installed ES File Explorer on our Android tablet and we have cataloged a remote server (10.10.19.45). I am able to see the files on this server from the tablet.
On a different desktop project, I have used a java.nio class file to copy files from a local folder on the desktop to the same remote server and it has been working fine. I tried to use the same java class to copy a file from the Android /sdcard/Download directory to the remote server and it will not create the file on the remote server. I tried specifying
File DestinationFile = new File("//10.10.19.45/sandbox/result.txt"); AND
File DestinationFile = new File("smb://10.10.19.45/sandbox/result.txt");
but neither one works. I keep getting the error "IOException: No such File or Directory". The first option worked for my regular desktop Java application. Is there anyway I can copy files from my sdcard/download directory to the samba directory I have catalogued on my Android? Thanks.

[REPAIR][ROM]LG Official Kitkat 4.4.2[stock] Fix 2G Only / Mobile networks settings

For those of you who activated 2G-only mode in your Mobile Network Settings and can't use that menu anymore due to crashes, there is a relatively easy way to reverse this condition and bring back the menu functionality while untoggling 2G-only mode.
1. Make sure your ROM is rooted (should be the default state of Paulicat's ROM).
2. Use ESFileExplorer (or a similar root capable file manager) to backup the contents of the following directory:
/data/data/com.android.providers.settings/databases/...
(Note that the critical file to backup is 'settings.db', the journal and other files are not critical but should be copied just in case)
3. Make a copy of 'settings.db' in a temporary location
(You will edit this copy of the database)
4. Use an SQLite editor (I used SQLite Debug) to open the 'settings.db' file you copied previously
5. Open the 'global' table and find (by the 'name' column) the row with 'name' that is 'preferred_network_mode'
6. Update the 'value' of this row from '1' to '0'
7. Execute your transaction and commit the changes to the table
8. Close the db and re-open it to verify that your changes have persisted
9. Return to '/data/data/com.android.providers.settings/databases/...' and delete the entire content of that directory
10. Immediately copy and paste the edited 'settings.db' file into the '.../databases/...' directory
11. Immediately turn off and restart your phone
At this point, you should have changed your phone's network preference setting from 2G only back to 2G/3G. This will also allow you to access the Mobile networks settings menu again.
I didn't find this solution for months because I didn't realize that the Android global settings database was stored in the above directory. I hope posting this here might help someone.
Reference: http://forum.xda-developers.com/showthread.php?t=2230207 (You may follow the suggestion to make this change via adb)

Backup and restore a Chrome extension?

I have an extension that is no longer available on the Chrome store. I'd like to be able to back it up on my Chromebook and restore it, since I think it will not be restored after I update the Chrome OS (it will presumably fetch the available extensions from the store).
My Chromebook is in developer mode. So I wonder can it be done from the shell?
I tried enabling developer mode in chrome://extensions, but pack extension does not allow me to see any system root directory, and I have the additional challenge of figuring out which extension it is in /home/chronos/user/Extensions/.
I'm not really sure where to go from here. Any help with this would be really appreciated!
beetroot said:
I have an extension that is no longer available on the Chrome store. I'd like to be able to back it up on my Chromebook and restore it, since I think it will not be restored after I update the Chrome OS (it will presumably fetch the available extensions from the store).
My Chromebook is in developer mode. So I wonder can it be done from the shell?
Click to expand...
Click to collapse
Can you see the ID of the extension at the very bottom of its listing in chrome://extensions/? If you can.... I just tested out the following with an extension chosen at random, and it worked fine for me, although I suppose it may depend on the extension...
Copied the ID of the extension (at the very bottom of its listing in chrome://extensions/), then:
sudo su
find / -iname theidoftheextension
cp -a -r /home/chronos/user/Extensions/theidoftheextension /media/removable/UNTITLED/
Back in chrome://extensions/
Clicked Packed extension > chose the folder above the one containing manifest (in my case /media/removable/UNTITLED/theidoftheextension/0.1.2_0/)
Clicked Pack extension
Opened /media/removable/UNTITLED/theidoftheextension/ in file browser
Dragged the newly-created packed extension /media/removable/UNTITLED/theidoftheextension/0.1.2_0.crx over chrome://extensions/
It installed! Actually I tested it three times, resulting in three copies of the extension. Having said that, if you only have one copy of the extension, perhaps it would be better to test the .crx out on another copy of Chrome first, in case it somehow overwrites/breaks the copy you have installed.
Nolirum said:
Can you see the ID of the extension at the very bottom of its listing in chrome://extensions/? If you can.... I just tested out the following with an extension chosen at random, and it worked fine for me, although I suppose it may depend on the extension...
Copied the ID of the extension (at the very bottom of its listing in chrome://extensions/), then:
sudo su
find / -iname theidoftheextension
cp -a -r /home/chronos/user/Extensions/theidoftheextension /media/removable/UNTITLED/
Back in chrome://extensions/
Clicked Packed extension > chose the folder above the one containing manifest (in my case /media/removable/UNTITLED/theidoftheextension/0.1.2_0/)
Clicked Pack extension
Opened /media/removable/UNTITLED/theidoftheextension/ in file browser
Dragged the newly-created packed extension /media/removable/UNTITLED/theidoftheextension/0.1.2_0.crx over chrome://extensions/
It installed! Actually I tested it three times, resulting in three copies of the extension. Having said that, if you only have one copy of the extension, perhaps it would be better to test the .crx out on another copy of Chrome first, in case it somehow overwrites/breaks the copy you have installed.
Click to expand...
Click to collapse
Thank you, Nolirum!
I did as you suggested, and installed Chromium in Crouton to test it. I get the error "This can only be added from the Chrome Web Store" when I try dragging in the .crx.
When I try 'Load unpacked extension' option in chrome://extensions I get the following error:
Failed to load extension from: /Volumes/KINGSTON/theidoftheextension/5.0_0
Cannot load extension with file or directory name _metadata. Filenames starting with "_" are reserved for use by the system.
Click to expand...
Click to collapse
I saw this on Stackoverflow about the error. I deleted the leading underscore from metadata folder and it works! Yay!!
https://stackoverflow.com/questions...ebstore-throws-error-package-is-invalid-detai
No problem!
Out of interest, when you dragged the .crx onto Chromium, and got the error, was that with dragging it directly into the list of extensions in the chrome://extensions/ window (where you see the icons, details, extension IDs etc)? Just wondering, as I get that error if dragging a .crx on to the browser address bar or on a webpage, but not if I drag it into the extensions list directly.
In any case, interesting info about the metadata folder nonetheless. I remember having to do the same (deleting the underscore) for some extension I was trying to edit. It's reassuring to to read that _metadata is just Web store hashes, and that modifying it shouldn't affect functionality.
Nolirum said:
No problem!
Out of interest, when you dragged the .crx onto Chromium, and got the error, was that with dragging it directly into the list of extensions in the chrome://extensions/ window (where you see the icons, details, extension IDs etc)?
Click to expand...
Click to collapse
Yes, I was dragging into the extensions list. When I try it a little popup says something like "drop to install" then the error.
Interesting. I don't get that error (tried on Chromium, too). Perhaps it depends on the extension. Thanks for checking.

To avoid Lg Bridge server error.

Found it on Reddit.
Creddit-Mapants
Open your file explorer, and navigate to:
C:\Users\Sagor\AppData\Local\LG Electronics\LG Bridge\SWUpgrade\PhoneLog
Change Sagor for your windows user name. There's a log file; PhoneSWUpgrade (maybe more than one, if so, open the latest dated one) Scroll down to the last you see: -> 18:51:45: [DLL]OpenURL url = http://pkg03.lime.gdms.lge.com/dn/d...1501825902&h=9df795682ab5a66d4102a40ca7277ffb
-> 18:51:45: [DLL]KDZ file size error Copy the link to your browser address bar, but delete everything after .kdz and change http://pkg03 to http://pkg02 and hit enter. The file will start to download. I know that's not the answer, you'd have to flash your phone, but it makes me wonder why LG Bridge is not doing it by itself?

[Q] How can I edit APK's library files (.so files)?

I want to install 2 different versions of an app. I researched a little and found that I need to change APK's package name with APK Editor. I decompiled the APK with APK Editor and changed everything related with package name. For example The app's package name was
Code:
com.oldapk.filee
, I changed to
Code:
com.newapk.file
. Then I compiled it again and installed new apk file. But I was unable to launch the new APK file, I enabled USB Debugging on my phone and started to looking crash logs. I saw that the package name was mentioned as
Code:
com.oldapk.filee
, I started thinking about what could It be wrong, I used
Code:
ack
on linux to check which files has
Code:
com.oldapk.filee
string and saw that 2 libraries (.so files) was including the old package name. I changed them in NotePad++ (Hex Editor Addon) to new package name but this time when the app launches, I was able to see starting screen but it was crashing in 0.5 seconds after I launched it. I checked the crash logs again and then I saw that the package name was still old. Maybe the changes that I made didn't effect. How can I edit these files?

Categories

Resources