System Administration, Reconfigurable Computing and Other Random Topics

Prevent autostart of Android File Transfer on macOS

Android File Transfer (let’s call it AFT) is a handy tool to transfer files from and to an Android device when using a Mac. This software has an annoying habit though: It automatically starts when an Android device is plugged in. Since on most modern Android devices, the user has to give permission to access files after connecting it to a PC, it opens up just to confront the user with an error message.

This behavior is caused by an App called “Android File Transfer Agent.app”, which is automatically installed by AFT to launch on login and wait for connecting devices. Here is what seems to happen on every launch of AFT to install this agent:

  1. “~/Library/Application Support/Google/Android File Transfer/Android File Transfer Agent.app” is replaced by “/Applications/Android File Transfer.app/Contents/Resources/Android File Transfer Agent.app”
  2. The Agent app is started
  3. An entry for this application is installed as a Login Item for the current user

People have come up with different hacks to sabotage this “feature”, e.g. renaming “Android File Transfer Agent.app” to something else in the /Applications folder or making the folder under ~/Library unaccessible for AFT. Unfortunately, these solutions have side effects, such as an increasing number of invalid entries in the user’s startup items. A more clean solution therefore is to replace “Android File Transfer Agent.app” by an application bundle that does nothing.

Creating a noop application

We can simply use the Automator to create an application bundle:

  1. Run Automator.app and create a new Application
  2. Since some action has to be performed, insert an empty shell script into the work flow
  3. Save the application as “Android File Transfer Agent.app” in your user’s directory

Replacing agent by noop application

  1. Stop any running “Android File Transfer Agent” using the Activity Monitor
  2. Remove app from ~/Library:
    rm -rf ~/Library/Application\ Support/Google/Android\ File\ Transfer/Android\ File\ Transfer\ Agent.app
  3. Replace the agent app under /Applications:
    sudo rm -rf /Applications/Android\ File\ Transfer.app/Contents/Resources/Android\ File\ Transfer\ Agent.app
    sudo cp -r ~/Android\ File\ Transfer\ Agent.app /Applications/Android\ File\ Transfer.app/Contents/Resources/

On the next launch of AFT, it will copy your noop app to your ~/Library folder and install it as a startup item. Since it is a valid app, this should not cause any issues. Of course, after an update of AFT you will have to replace the agent app under /Applications again, but the last update was in 2012, so I wouldn’t worry too much…

Ironically, four days after I released this post, Google actually released an update (1.0.11). Make sure to read Donald’s comment below since the location of “Android File Transfer Agent.app” within the application has changed.

4 Responses to Prevent autostart of Android File Transfer on macOS

  1. Donald Burr says:

    On my copy of Android File Transfer, the Android File Transfer Agent app was not in Contents/Resources but was instead located in Contents/Helpers. So the commands I had to run as part of Step 3 were:

    sudo rm -rf /Applications/Android File Transfer.app/Contents/Helpers/Android File Transfer Agent.app
    sudo cp -r ~/Android File Transfer Agent.app /Applications/Android File Transfer.app/Contents/Helpers/

    Other than that this worked perfectly for me. Thanks!

  2. James says:

    A note: Can one achieve the same by creating an empty executable file without sing automator?
    That is: Remove the agent ; creat an empty file i the same place with the same name with “touch” ; make this empty file executable

    rm “/Applications/Android File Transfer.app/Contents/Helpers/Android File Transfer Agent.app”
    touch “/Applications/Android File Transfer.app/Contents/Helpers/Android File Transfer Agent.app”
    chmod +x “/Applications/Android File Transfer.app/Contents/Helpers/Android File Transfer Agent.app”

    I haven’t tried this since I have a script instead which I find more covenient if more verbose, which is less sensitive to updates:

    open /Applications/Internet+phone/Android File Transfer.app &&
    sudo killall ‘Android File Transfer Agent’ &&
    sudo killall ‘Android File Transfer’
    osascript -e ‘tell application “System Events” to delete login item “Android File Transfer Agent”‘
    rm “~/Library/Application Support/Google/Android File Transfer/Android File Transfer Agent.app/Contents/MacOS/Android File Transfer Agent”

    i.s. as I said on the other site, this opens file transfer when needed and closes all the annoying processes when the andriod process (i.e. file window) is shut.

    This android is a pain. If the plain phone method was not so buggy, I wouldn’t touch the google solution with a bargepole.

    • Michael says:

      Whether a simple executable script would work as well is a good question. I haven’t tested this. If I ever have to revisit this problem, I’ll give it a try.

      By “plain phone method” you mean MTP? It would be nice if macOS would add native support for it so one could simply use Finder to access the phone’s storage.

  3. Paul Anderson says:

    This really should be elevated in search results against the solutions that rename the apps or run scripts to kill the process. I swapped in the no-op app and now what’s done is done. Thank you for a great fix.

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha loading...