I am having difficulty importing a project written on Android Studio 1.1 into Android Studio 2.1.2. I keep getting this error whenever the gradle is building before testing
I could install app on Nexus, but couldn't on Samsung. Nothing helped me except the change of the USB cable.
This problem occurs when you copy paste class and didn't change package name. Means Package name are different. Build has no problem to build but its problem to install.
You just need to restart your adb. Instruction for that is given in this Link
Note: The top answers recommend to disable Instant Run. Try this before exploring my listed solutions to prevent wasting more time than needed.
Here are some possible solutions:
1) Make sure that your phone is properly connected to your PC with a USB cable: Before going over these fixes, make sure that you have at least connected your phone to your computer properly. If it's properly connected, your phone should be charging.
2) Make sure that your device's driver software is up-to-date: Simply go to your File Explorer and then right click Computer
. Then, select Manage
(requires administrator privileges). In your Computer Management window, find a tab on the left pane that says Device
or Device Manager
. Search for your device from there. Mine was under Portable Devices
and the name started with SAMSUNG
, so finding your device shouldn't be too hard. Right click the device, and then select Update Driver Software...
. I chose the Search automatically for updated driver software
option, since it's much easier.
3) Enable USB debugging
under your Developer Options
: For my Samsung Galaxy S9, I found mine under Settings
> Developer Options
. From there, enable USB Debugging
. If you can't find your Developer Options, find your build number within the settings and tap it 7 times consecutively. I found mine under Settings
> About Phone
> Software information
.
4) Make sure you've allowed USB debugging for your specific computer: Although you may have your USB Debugging
option enabled, you still need to allow USB debugging for your specific computer. A popup should appear asking Allow USB debugging?
and providing the computer's RSA key fingerprint. Before pressing OK, make sure your check Always allow from this computer
, so that you don't have to go through this again in the future. If you think you've done this but yet your device is still marked as OFFLINE
, select the Revoke USB debugging authorization
option in 'Developer Options'. Then, re-allow your computer for USB Debugging. If the popup doesn't appear, reconnect your phone to the Computer (pull the cable out and put it back into your Phone).
5) Trying cleaning AND rebuilding your project: In Android Studio, open up the Build
tab at the top left and try both the Clean
and Rebuild
options.
If none of the above works out: Reinstall Android Studio by Uninstalling the program and re-downloading the setup file here. Scan for any viruses that may be affecting your computer. Check for any sort of error while reinstalling Android Studio. If none of the methods presented in this answer work, fetch for support here.
Good luck.
It's a bit late for reply but, i've figured out how to solve this problem on Android Studio 3.1.
You can have "Instant Run" checked, what you need to do it's just to build an APK
and then retry to Run your app.
Hope this help!
I was using CyanogenMod 12.1 and was building with libgdx when I met with the same error. Rebuilding didn't work for me. My phone was connected as UMS or USB mass storage to my PC when I ran the app. Just changed the USB configuration from mass storage to MTP and it fixed my problem.