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

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
Disable instant Run (Not an option anymore in Android Studio >=3.5.1)
Enable USB debugging, connect using the device using "Transfer Files" mode and not "Charging Device" Mode
Turn off MIUI Optimization and Reboot
Uninstall App and re install
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

How I solved it:
Disable "Use libusb backend" in the Settings -> Build, Execution and Deployment -> Debugger
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

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

Related

android studio times out installing the app

I have a question about running an app through the emulator on android studio.
My emulator device is able to turn on, but when running the app, install never completes so the app times out. I have tried invalidating cache and restarting, and I have installed the sdk platforms that are the same as the emulators and project, but these changes did not work. My computer cannot install emulator hypervisor driver for AMD processors or intel x86 Emulator accelerator, but I don't think it is necessary for the app to run since my emulator can turn on, right? also, any app has never successfully run on android studio.
The is no code other than the hello world that comes up automatically. This is an empty project with a minimum sdk of api: android 4.1. The device I am using is a pixel 2 with an api of 22. (size on disk 3.5 GB) for tools, I have android SDK build-tools 33, android emulator (31.3.10), and android sdk platform- tools (33.0.3) installed.
I have tried every forum that has the same issue as me but if you think there is one that can help me, please share it thanks.
Android Emulators aren't always the best so expect random failures. This is what I would try:
Make sure the app compiles properly (make sure you see BUILD SUCCESSFUL in your bottom "Build" Tab in Android Studio)
Make sure you have updated Android Studio and Android Emulator, Android Build Tools, SDKs etc.
Create and use a device with a higher API version. Ideally one with Play Store.
Depending on your development machine you might want to try a different architecture (ABI). Try x86 or x86_64 instead of what you've already tried.
In rare cases your existing emulator images get corrupted. Uninstall them in your SDK manager (Show Package Details) and install them again.
If possible try running the app on a real device (follow online instructions to enable USB debugging etc.) to verify the emulator is the problem.

Android studio 4.1 emulator crash

I just upgraded my android studio to 4.1 version:
And tried to run some project on this emulator:
And for some reason, this specific emulator is crashing my android studio, I have noticed that I am getting an error:
After reading about the subject, I uninstalled "Riot Vanguard" but it did not solve my problem.
More info (and partially solving the problem ) can be found in "Update" at the bottom of the question.
In addition, moments after my android studio will get closed I will get a windows blue screen (happens every time).
I didn't have this problem earlier with android studio below 4.1 version, why is this happening?
Update (problem solved for others emulators)
I have run into the same problem on other emulators as well, but I could open those emulators so I could fix the problem:
Solution 1
According to most threads that I have run into, You will need to disable or uninstall "Riot Vanguard":
Open task manager, go to the startup tab, right click on Riot Vanguard, and press disable
Solution 2
If step 1 didn't fix the problem you may want to enable developer mode on your emulator.
For some reason with android studio 4.1 android studio could not find the emulator (It will tell you that there are "No connected devices") without enabling the developer mode
Before Android studio 4.1 version I didn't need to enable the developer mode to run projects on emulators and this is what solved the problem for other emulators for me.
BUT
Although I don't have any problems with other emulators at all I still can`t even open Pixel_3a_API_30c68 emulator without it crashing
How can I fix this problem on the specific emulator?
Update 2
The problem still occurs even After updating android studio to 4.1.1
Without having "Riot Vanguard" I also could not run any emulator in Android Studio since I upgraded to version 4.1. After some hours I finally found out what caused the problem (in my case):
"Android SDK Tools" have been replaced by other SDK tools (which ?) and is obsolete now. As soon as I UNINSTALLED "Android SDK Tools" the emulator worked again.
I would be interested to know if the java version makes a different. I moved from Windows to Linux because of problems running the emulator.
Linux worked great until I moved to Android Studio 4.1. So check java and it was version 11. Changed to java8 and it worked straight first time.
Seem to remember there was a setting in Android Studio to set the SDK which I think was version 8. But can no longer find this in settings in Studio 4.1.
Updating to the latest system image of the SDK helped me.

xamarin Visual Studio 2015 apk fails to install: Error "parsing the package"

Wrote app for an android device whose installed Android version is Lollipop 5.1 (AZPEN A1040 tablet - latest version available for it).
The app installs and works correctly in the emulator (setup to emulate a Lollipop 5.1 device)
However, after archiving without any issues, when attempting to install the app's apk file to the actual target device, I get the following error:
"There was a problem parsing the package"
The project's properties in Visual Studio 2015 are displayed in the graphics below:
All the referenced libraries in the project are shown in the picture below:
I have neither errors nor warnings during the build, deploy to emulator or archiving processes.
The target device has already the following settings enabled:
"Allow installation of apps from unknown sources"
"USB Debugging" (installation has been attempted with this setting on or off without success)
EDIT: To add pertinent info based on comments below
The apk is signed (previously archived apks have worked correctly.
New code has been added since those working apks, but as mentioned I
have no errors or warning when building the latest apk).
Have not tried archiving in Debug mode (not sure if it will let me,
not sure I'd like to try since this is for a client).
The apks are named during archiving process. After the creation,
apk file's name has not been changed(I did change the 'suggested'
name to something shorter during the archiving process, but did it so also for the previously working apk vesions whose installation worked on the target device).
At this point I'm at a loss as to what to do to make this install on the target device.
Any ideas?
I was receiving this issue and the problem was because I had multiple versions of the "Android SDK Build Tools" installed.
To see if you have this, go to the Android SDK Manager, and look under Tools.
If you have multiples, uninstall all the extra ones and rebuild your package.
As soon as I did this, I was able to deploy/install this package w/out hassle.
Note that the package that wouldn't install on the device WOULD install in the emulator(I'm using Visual Studio Emulator for Android).
Figured it out what the issue was. The settings on the device under "About Tablet" displayed the Android Version as 5.1. Because of that, I set the Minimum Android Target in the Visual Studio project as "Android 5.1 (API Level 22 - Lollipop)".
After reading #Jon_Douglas' comment, I decided to bite the bullet and ask the client to let me use his device for troubleshooting. Once I connected the device, Visual Studio picked it up as "AZPEN A1040 (Android 5.0 - API 21)".
I changed the Minimum Android Target to "Android 5.0 (API Level 21 - Lollipop)" and was able to install the apk. Compare the settings image below to the one initially provided above:

Android Studio Not Deploying App

I currently have the latest version of Android Studio and I'm trying to deploy an app onto my phone running Android 5.0.1 Lollipop. After building, the terminal shows that the apk is being installed onto the phone and the status indicates that it is running. However, nothing shows up on my phone (no running applications and the app does not show up in the installed applications list). I've tried disabling auto-run in studio settings but it doesn't help. Any ideas why it's doing this? Also I reinstalled the adb driver just in case that was the cause. It might be helpful to note also that this happens even on the default template apps generated by studio.
try to turn off the Instant Run
File - Settings - Search Instant Run , unselect all the options
Hope this would help.
In my case the 'HMS Toolkit' (version 6.3.0.3003.AF) plugin, on Android Studio Chipmunk (version 2021.2.1), was causing this.
I've disabled it and it all started working again.

Xamarin.Android Projects failed to deploy in visual studio emulator for android

I'm using visual studio 2015 update 1 with windows 10 build 10586 TH1.
also I'm using Xamarin Version 4.0.1.96.
I have created a blank Xamarin.Forms app. It deploys to Windows Phone emulators without any issue. But unable to deploy to Android Emulators.
When I start android project Android Emulator launched successfully but visual studio freeze at this step.
I've tried a lot of android emulator profiles but cannot solve the problem.
This problem only exists for Emulators and project successfully deployed on physical android device.
I have the same issue with Xamarin.Android projects.
Here is all of the text in output window:
1>Starting deploy 4.5" KitKat (4.4) HDPI Phone ...
1>Starting emulator 4.5" KitKat (4.4) HDPI Phone ...
1>Validating emulator arguments...
1>Determining if emulator is already running...
1>Preparing virtual machine...
1>Launching emulator...
1>Emulator launched successfully
Thank you in advance for your help.
I was running into the same issue with the emulator starting up find but Visual Studio getting hung on the build/deploy. Finally figured it out from here.
Visual Studio gets stuck trying to deploy the app to the emulator or the emulator does not appear as a debug target in other IDEs
If the emulator is running, but it does not appear to be connected to
ADB (Android Debug Bridge) or it does not appear in Android tools that
make use of ADB (for example, Android Studio or Eclipse), you may need
to adjust where the emulator looks for ADB. The emulator uses a
registry key to identify the base location of your Android SDK, and
looks for the \platform-tools\adb.exe file under that directory. To
modify the Android SDK path used by the emulator:
Open Registry Editor by selecting Run from the Start buttons context menu, typing regedit in the dialog box, and choosing OK.
Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools in the folder tree on the left.
Modify the Path registry variable to match the path to your Android SDK. Restart the emulator and you should now be able to see the
emulator connected to ADB and associated Android tools.
The value in my registry was set to "C:\Program Files (x86)\Android\android_sdk" (or similar). Updating it to "C:\Users\{USERNAME}\AppData\Local\Xamarin\MonoForAndroid\AndroidSDK" solved it for me. (I haven't yet worried about how to make this work for all users.)
I had the same issue but in my case it was not the registry. After doing a release build, I deployed the app to the emulator device in release mode which pushes the app to the device and then effectively "disconnects". These leaves a version of the app on the device which seems to block further attempts at debugging.
I solved it by starting the emulator, going to "settings -> apps" and manually uninstalling my app. Then the next debug build & deploy worked again.
I had the same issue. After a long struggle i fixed it.
Sol 1 :
Check with the registry as mentioned by others.
**HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools**
Sol 2 :
In my case there is no android-SDK tool found in registry. So you have to add the registry manually here "**HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node**"
you can add it by right click on **Wow6432Node** => **New** => **key**.
Set Key name as **"Android SDK Tools"**then right click on **Android SDK Tools** =>**New** => **String Value**
Set Name as **Path** for newly added string. Then right click on **Path** => **Modify..**
Copy the Android SDK Tools path from program files and paste in Value Data.
Now the registry is created manually. You can debug the project via emulator.
Note : Don't forgot to restart the system.
Have a look here:
Xamarin Forms Android App Crashes Running Debug with VS Android Emulator
Start the Hyper-V manager
Select the emulator you are trying to use
Right-click, hit settings
Click processor
Click Compatibility
Set checkbox “Migrate to a physical computer with a different processor version”
You do not have this issue on a laptop because its processor does not provide the new features which are unsupported by the Android Emulator for Visual Studio. The described tweak is only needed on PCs with newer CPUs.
I got round this problem by starting Visual Studio as an administrator.
I too have had weirdness with the Visual Studio Emulator for Android and visual studio appearing to be stuck at the "Deploying ..." step trying to launch the app for debugging.
What I discovered is that restarting both the emulator and visual studio seems to make things better for me once it starts to do this.
Also, when debugging an app, it seems that exiting your app normally helps compared to when using the "Stop Debugging" button.
For example, I started my app twice and killed it w/ the "Stop Debugging" button, but couldn't deploy/start the app a 3rd time w/out a restart of visual studio and the emulator.
Am using VS 2015 Community edition w/ update 3.
I just had a very interesting experience,
In my case the registry path to SDK was correct,
I had unchecked the "Use Fast Deployment" (under packaging properties in android options), and
all my efforts to reboot the PC, close VS, Close Emulator start over had failed.
However I did these two:
1 - Updated all the components in android SDK manager and restarted the PC,
2 - Disabled my anti-virus! and then suddenly VS deployed the app to the emulator!! (It was stuck in the same situation where the emulator starts and nothing happens!, I did this out of despair!)
(OS: win 7, professional, VS 2017 Community edition!)
More Details
I have been trying this for three more days
For my special case disabling the Anti Virus seems to solve the issue every single time!
The solution for me was to Check the deploy box in the Configuration Manager
This answer came from Xamarin Forum

Categories

Resources