Android Blog

Alternative to MTP to transfer files between your smartphone and your computer

posted 22 Mar 2017, 06:07 by Dominique Cressatti   [ updated 29 Jun 2018, 11:10 ]


If in you've been transferring files between your Android smartphone and you computer over MTP, you must have noticed that it is a painfully slow and an unreliable experience, especially if like me you're using Linux. Here's a crafty alternative using USB tethering and an FTP server running on the smartphone, which will also let you access the whole content of the smartphone SD Card, rather than just the pictures and music folders when done with MTP. USB tethering works using Ethernet over USB which creates network interfaces to which IP addresses can be assigned. So basically once you've plugged your smartphone to your computer with a USB data cable and enabled USB tethering, an Interface named: RNDIS with the IP address: 192.168.42.129 gets created on the smartphone and an Interface named: usb0 with an IP address within: 192.168.42.0/24 gets created on your Linux Box. 

And then all you need is to run an FTP server on your smartphone. There are a lot of FTP server applications on the Google Playstore but personally I use the builtin FTP server that comes with ES File Explorer Pro, which allows me to upload to and download files on my smartphone. If you're looking for a free alternative, rather than pay for ES File Explorer Pro, here is a copy of the last free version of ES File Explorer before it's been bloated it with adware (bear in mind that to install it, you'll have to enabled Unknown sources under Settings ➡️ Security). 

Wrapping it up, here's an example based on using ES File Explorer and a Linux box:
  1. Plug your smartphone to your Linux box with a USB data cable.
  2. On you smartphone, go into  Settings ➡️ Wireless & Networks ➡️ More (or plus) ➡️ Tethering & Portable Hotspot ➡️ USB Tethering and enable it.
  3. Make sure that you've been assigned an IP address on usb0. If not assign one manually.
  4. Make sure that you can ping 192.168.42.129.
  5. Launch ES File Explorer, go into Menu ➡️ Network ➡️ Remote Manager and turn it on.
  6. Launch an FTP client on your Linux box pointing to 192.168.42.129 on port 3721.
Here's what it looks like on my Linux box. Accessing the content of the SD Card over FTP, using KDE Dolphin.


Troubleshooting:
  • Obviously if you can't ping your smartphone on 192.168.42.129, you're not going to get anywhere.
  • Check if you can connect to your FTP server over WIFI. If it doesn't work then you have a problem with the FTP server.
  • If you're using ES File Explorer make sure that in the Settings you have sett the root directory to your SD Card correct path. Otherwise if you've set it to / and your device isn't rooted, it won't work.
  • Check that your FTP server isn't restricted to listen on a specific IP address and excluding 192.168.42.129. To do that you can connect to your smartphone over and ADB shell session and type netstat -ant. Using ES File Explorer, this is what I get. My FTP server is running on port 3721 and listening on all IP addresses (yeah I know listening on all IP addresses can be a security risk but in this particular case, only if you still WIFI enabled and allow anonymous access).

TWRP - Failed To Restore Data / Error Sending Message To Add Storage 65537

posted 18 Jan 2017, 08:58 by Dominique Cressatti   [ updated 29 Jun 2018, 11:11 ]


OK don't panic if in TWRP:
  • Restoring a ROM fails at restoring the Data partition
  • When you try to format the Data partition you get "Error Sending Message To Add Storage 65537"
  • You install a custom ROM successfully but it never fully boot
While flashing the system partition or restoring a backup.

Chances are that because of a bug in some version of TWRP, sometimes MTP gets enabled by default when you go into recovery, thus prevents R/W access to the data partition. 

To fix it, in TWRP (obviously!), go to Mount ➡️ Disable MTP and try again 

Android - "UIDS on the system are inconsistent" error

posted 10 Sept 2015, 08:24 by Dominique Cressatti   [ updated 29 Jun 2018, 11:11 ]


A few times, probably after using Link2SD to move an app from the SD card to the phone internal storage or convert a user app into a system app, I received the following message



Although it looks scary, it is easy to fix. The key to resolve the error is to look on your device in:

/data/system/uiderrors.txt


If you have rooted your device, which if you've been using something like Link2SD is most likely, use something like ES File explorer, making sure that you've enabled root access and open the above file, scroll to the bottom of the log to find and delete the APK which is causing the error. Otherwise, read on!



Here is an example of mine where the package "com.wordreference" was the cause of the problem.

  1. Connect your device to your computer, fire up ADB and get a shell session

    wisedom@wisedom-thinkpad ~ $ adb devices

    * daemon not running. starting it now on port 5037 *

    * daemon started successfully *

    List of devices attached

    01547AE81900F006 device

    wisedom@wisedom-thinkpad ~ $ adb shell


    Above, I've checked that my device (in bold) was connected before firing up a shell session.

  2. Display the content of /data/system/uiderrors.txt root@android:/ # cat /data/system/uiderrors.txt    

    08/04/2015 18:13: No settings file; creating initial state

    4/8/15 8:20 PM: Need to read from backup settings file

    4/8/15 9:21 PM: System package com.google.android.ears no longer exists; wiping its data

    ….

    ….                                                                                                                        

    29/06/2015 07:04: System package com.vp.alarmClockPlusDock no longer exists; wiping its data 02/07/2015 20:10: Need to read from backup settings file

    06/07/2015 12:18: Need to read from backup settings file                                

    09/07/2015 21:31: Need to read from backup settings file                                

    09/07/2015 21:31: Package com.wordreference has mismatched uid: 10085 on disk, 10127 in settings

    10/07/2015 00:14: Need to read from backup stopped packages file

    Above (in bold), you can clearly see which package was responsible for the error.

  3. Next, all needed to be done was to delete the package (I had 2 my in case). root@android:/ # rm /data/app/com.wordreference-1.apk root@android:/ # rm /data/app/com.wordreference-2.apk
  4. Reboot your device to finish.

1-3 of 3