Android Studio refuses to build and install any app on my phones

1.5k Views Asked by At

Since the time I have updated android studio to 3.5, I have been unable to run any app on multiple of my physical phones (Redmi Note 4 and OnePlus6). The app isn't installing on any of them. But it is installing on the emulated devices of the same respective versions (Android 24 and Android 28), so it is not an issue with the code.

Moreover, I tried to build the previous versions of my app stored on Git, and now Android Studio does not build the app showing - "linking error". While that same code version was working fine a few months ago (prior to the android studio update). Which is why I think the problem is somehow with the Android Studio and not the code...

Things I have tried

  1. Disable instant Run (Not an option anymore in Android Studio >=3.5.1)

  2. Enable USB debugging, connect using the device using "Transfer Files" mode and not "Charging Device" Mode

  3. Turn off MIUI Optimization and Reboot

  4. Uninstall App and re install

  5. Build the apk, transfer the apk to the device and then try the install (This works on OnePlus 6 but not on Redmi Note 4)

The apps I have tried target Sdk >=27, and use androidx. However, I tried to go back to a previous version of the app, which didn't use androidx (and used the legacy support libraries), but still got the same error.

My system is Ubuntu 18.04, and current Android studio version is 3.5.3

Errors I have been getting include:

  • INSTALL_FAILED_USER_RESTRICTED
  • Device Not Found

UPDATE: - Just tried to install on OnePlus6, doesn't install there as well. Earlier I had tested only for Redmi Note 4. - Tried uninstalling and reinstalling the app, building the apk and transferring on the phone then manually installing. - This is happening across projects, at least for Redmi Note 4. I tried this with one of my course projects, same/similar problems.

My guess is problems with Android Studio update and the recent migration to androidx from the "legacy" support libraries

2

There are 2 best solutions below

0
On

How I solved it:

Disable "Use libusb backend" in the Settings -> Build, Execution and Deployment -> Debugger

Screenshot of the settings page where we need to disable "use libusb backend"

Sorry Android Studio 3.5 for the curses

How I found the solution:

I checked the logs of android studio by going to Help -> Compress Logs and Show in Files. In the folder which opened, I saw the logs by the name adb.1000.log (because adb - android debug bridge, handles the communication with the device). In the last few lines I saw - "read transfer failed: LIBUSB_TRANSFER_CANCELLED". I read here about the option of libusb

1
On

Did you try to clean/rebuild... under /Build/Clean Project, after that /Build/Rebuild Project and after cleaning and rebuilding you can try under /File/Invalidate caches