If you’re an Android device owner with a Mac, chances are you’ve installed the rather rudimentary app called Android File Transfer. This app gets one useful job done, namely to transfer files between Mac and Android. Yet, for many of us it’s a nuisance that Android File Transfer launches every time you plug your Android device into the computer. In my case, I rarely need to use AFT. I mostly plug my phone in for tethering purposes. 

So, here’s how to disable AFT from launching automatically. I found numerous solutions to this issue, but most had become redundant as AFT was updated, or are too complicated for many people. Credit for this solution goes to krischik on Github.

In Terminal launch change to the directory where you want the script, and then create a new file with nano:

cd /path/to/where/you/want/the/script
nano aft-disabler.sh

Then paste in the following code:

#!/bin/zsh

typeset PID=$(ps -fe | grep "[A]ndroid File Transfer Agent" | awk '{print $2}')

if [[ -n ${PID} ]]; then
kill ${PID}
fi

for AFT in \
"/Applications/Android File Transfer.app" \
"/Applications/Sync/Android File Transfer.app" \
"${HOME}/Library/Application Support/Google/Android File Transfer"
do
echo "### Look for agents in “${AFT}”"

if test -e "${AFT}"; then
for AFTA in \
"${AFT}/Contents/Resources/Android File Transfer Agent.app" \
"${AFT}/Contents/Helpers/Android File Transfer Agent.app"
do
echo "# Look for agent “${AFTA}”"

if test -e "${AFTA}"; then
mv -v "${AFTA}" "${AFTA}.DISABLE"
fi
done; unset AFTA
fi
done; unset AFT

osascript -e 'tell application "System Events" to delete every login item whose name is "Android File Transfer Agent"'

You’ll then need to make the file executable, and run it:

chmod u+x aft-disabler.sh
./aft-disabler.sh