Tutorial: Transferring files to your MTP-only Android device

Chances are if you like Open Source and Linux you like Android, since it’s both Open Source and Linux. Quite ironically though many new Android devices, specially the very Open Source community friendly Nexus line, don’t support the USB Mass Storage Protocol, instead Android relies on MTP (Media Transfer Protocol), sadly it doesn’t quite work in Linux distros, although you may get MTP to work you’ll get transfer speeds of around 5 Kb/s or 17 minutes to transfer a 5 Mb MP3 (if you’re in this kind of situation, of either not being able to transfer anything or transfers taking forever, you probably ended up with a cool, but annoying if forced, wireless workaround like AirDroid).

Thankfully, there’s a solution. Android has a command line tool known as ADB (Android Debug Bridge) which has plenty of options for developers, among those, transferring files between your computer and your Android Device.

So let’s install ADB in Netrunner, for that you need the Android SDK for Linux, which you can download from here or by running the following command:

wget http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz

You need Java to run this SDK, if you’re using (K)Ubuntu you need to install it by executing:

sudo apt-get install openjdk-7-jre openjdk-6-jre

If you’re using Netrunner, since is packed and ready for almost everything you throw at it, you already have it.

Now we need to extract the SDK, go to the location where you saved it, if you used wget to download it is right there in your home folder, and right click it and select Extract Archive Here, if you downloaded using wget just run:

tar -xvzf android-sdk_r20.0.3-linux.tgz

Now we need to open the SDK, just navigate to the tools folder inside the Android SDK and double click on the android file. If you’ve been using the command line all along you can run the following command:

 exec ~/android-sdk-linux/tools/android

Android SDK Manager should appear, check the status of Android SDK Platform-tools under the folder Tools, if it says installed, you can close the SDK, otherwise you need to tick it and click install packages, make sure the line looks like this:

Before we can use ADB we need to add the corresponding path, for that we need to edit the bashrc file in the home. If you want to use the GUI, open Dolphin and click on Show Hidden Files:

Find the .bashrc file (it’s closed to the bottom) and open it, now you just need to add the line:

PATH=$PATH:~/location/android-sdk-linux/platform-tools/;export PATH;

And replace location with the folder in which the Android SDK is. Once again if you’ve been using the command line, you can simply run this command:

echo ‘PATH=$PATH:~/android-sdk-linux/platform-tools/;export PATH;’ >> .bashrc

To make this change effective immediately let’s run:

source .bashrc

Finally we have a fully functional ADB installed. Now we just need to enable debugging mode in our Android device, first we need to enable Developer options, this is found on Settings > Developer options, there’s a toggle to turn it on, then we need to scroll down and tick Android Debugging, it should look like this:

To copy files from your computer to your device you need to run the following command, the first part is the location in your computer of what you want to send, and the second part is where you want it to be in your device:

adb push /what-you-want-to-copy /where-you-want-it

 To copy files from your device to your computer you run the next command, it’s mostly the same except the first bit is the location in your device and the second in your computer:

adb pull /what-you-want-to-copy /where-you-want-it

So this is basically all you need to know to transfer files using ADB, but as you may have notice it isn’t precisely convenient if you don’t like the terminal or very user friendly, but don’t worry!

Now that ADB is working we can install a nifty tool (a frontend) by a developer named Sole (I’m guessing is short for “Soledad” since she’s from Barcelona): The Android ADB File Manager.

First we need to install git:

sudo apt-get install git

And then we just need to clone the repository

git clone git://github.com/sole/aafm.git ~/aafm
(if you don’t want it in your home folder, just change the location)

To run this app (if it’s in your home folder, if not, change the command accordingly) we need to use Python:

python ~/aafm/src/aafm-gui.py

And, finally, a simple UI to transfer files between Netrunner and your Android device:

You can drag and drop files between the panels to copy them, and you can also drag from Dolphin to the device side to send a file, or from the device panel to Dolphin to receive a file, or you can right click any file or folder to copy, delete, or rename it, or refresh the current view or creating a directory:

Just a warning, according to the developer when dealing with large files it seems as if the app has hanged, but in fact is just waiting for ADB to finish, I’ve yet to experience this behavior, but if it happens to you, don’t worry. So there it is, I hope this has help some users, finally you can transfer files from Netrunner to your Android Device at full speed, now all that remains is enjoying how well both of your devices work together.

  • deeKAY

    NICE ONE 

  • Telebysat

    Thanks, worked very well, took me some time to find this, can’t understand why Android (opensource linus) can’t easily connect to linux systems!

    Using Opensuse 12.2

    Regards