[Nexus 7 (2013) General] sfhub:
The MTP fix is ONLY for the STOCK ROM and handles the case

USB debugging disabled - MTP working

USB debugging enabled - MTP not recognized

If you cannot get MTP working at all, I suggest you

uninstall your current device drivers

using device manager/devmgmt.msc or Nirsoft USBDeview

you may want to

set devmgr_show_nonpresent_devices=1

prior to starting devmgmt.msc and

view hidden devices within devmgmt.msc

REBOOT

reinstall

The ADB fix is for getting ADB to work while in Recovery (tested on stock and twrp).

Google USB device drivers can be found here:

Driver info/download - http://developer.android.com/sdk/win-usb.html

Direct download - https://dl-ssl.google.com//android/repository/latest_usb_driver_windows.zip

Nirsoft USBDeview can be found here:

http://www.nirsoft.net/utils/usb_devices_view.html

use this to remove old driver assignments, sort by date and choose Nexus 7 entries

====

MTP mode

(with USB debugging enabled)

I got tired of having to disable USB debugging to get the MTP device recognized.

This happens because the USB ID for the MTP device changes when USB debugging is turned on and isn't recognized by windows anymore. The particular problem is the compatible IDs list from the tablet is not advertising USB\MS_COMP_MTP when USB debugging is enabled and windows doesn't know to use the MTP drivers.

I created the following driver .inf file to fix the problem so you can have usb debugging enabled and still have MTP working.

I only tested it on Windows XP.

This ONLY fixes the problem where MTP works with USB debugging DISABLED, but stops working when you have USB debugging ENABLED.

If you can't get MTP working under any circumstance, you have some other problem. Try

double checking

Settings->Storage->3 dots->USB computer connection->Media device (MTP) is enabled

removing your drivers using Nirsoft USBDeview and rebooting

When you turn on USB debugging and windows asks for an MTP driver, just provide the following and it should install the driver hooks and start recognizing the MTP device from that point on.

Let me know if there are any issues and I'll try to address.

mtp_driver.zip is for USB debugging enabled and stock ROM

INFO: this same method of fixing the unrecognized IDs might not work for custom ROMs. I have forced the MTP USB ID for a custom ROM to be recognized and it does so successfully, but when the windows MTP driver tries to initialized the device, it fails. This indicates there may be additional issues with the MTP support on the custom ROM side.

====

ADB support

(within Recovery)

I wanted to get adb working in TWRP and adb sideload working in stock recovery but adb wasn't recognizing the device.

Here we have the same problem as above. The USB IDs for the ADB interface change when you are running Recovery and are no longer recognized by the driver. You'll notice that when you are running TWRP you will see an unknown device called "flo". This is actually the ADB USB interfaced but windows doesn't know that.

I created a simple fix for this problem. Just download the official Google USB/ADB drivers from above. Then download android_winusb.inf.zip from the attachment. Unzip the Google drivers and replace the android_winusb.inf file in the Google drivers with the one in the attachment.

android_winusb.inf.zip - unzip this file to get android_winusb.inf. Replace the file of the same name in the Google USB drivers with the one in this zip file

If you feel replacing a file is too complicated, the following attached file has all the changes done for you. Just unzip to get the adb_driver folder, right-click on the "flo" device, choose install drivers, and point the driver install to the adb_driver folder

adb_driver.zip - if you want everything already done for you, this file includes the driver inf and the driver so you don't need to replace anything. This will work for adb within both Android and Recovery.

platform_tools.zip - this is adb 1.0.31 that supports RSA identification introduced in Android 4.2.2

====