Android Studio Application Installation failed - android

Sometimes when I go to build and test my apps I get this error and it drives me off the wall. I never had to deal with this before.
Installation Failure
com.android.ddmlib.InstallException: 'cmd package install-create -r -t --full -S 2816556' returns error 'Unknown failure: cmd: Can't find service: package'
I tried following this guide here
Application Installation Failed in Android Studio
I did all the suggestions disable instant run, build apk then rebuild app, restart computer, restart android studio, use different virtual device.
Idk anymore any ideas? I am using Android Studio 3.4.1
Update: Fixed it my issue sorta. If i first launch my virtual device and get it loaded. Then run my app the error doesn't pop up. This leads me to believe that Android Studio will throw the installation error because it can't run the app on the virtual device since it takes forever to load on my laptop

Related

Android Studio returns error "Installation failed due to: ''cmd package install-create..."

I'm working on an Android App in Android Studio.
After updating Android Studio to Bumblebee 2021.1.1 Patch 2 it has stopped working.
Now I get the following error:
Installation did not succeed.
The application could not be installed.
List of apks:
[0] 'D:\Filer\Dokument\...\app\build\intermediates\apk\debug\app-debug.apk'
Installation failed due to: ''cmd package install-create -r -t --user current --full --dont-kill -S 4617721' returns error 'Unknown failure: cmd: Can't find service: package''
Retry
Failed to launch an application on all devices
Any ideas how to solve this?
The problem is most likely with the Android Emulator in Android Studio.
If you do a Cold Reboot of the Android Emulator it will most likely solve your problem.
Open the Android Studio Device Manager from Tools -> Device Manager.
Close the Android Emulator if still running.
Click on the Android Emulator's Device Menu ▼ located on the right hand side in the Device Mananger and Choose Cold Boot Now.
Now, try to run the app again...

react-native run-android not detecting emulator or device

When I run react-native run-android to run my React Native app I get this error and then the build fails:
'C:\Users\Alex\AppData\Local\Android\Sdk/platform-tools/adb' is not recognized as an internal or external command,
operable program or batch file.
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
I get this error whether I run the command with my phone connect by USB or if I run it with the emulator open from Android Studio. However, when I run adb devices both the emulator and my device show up.
I am pretty sure it is not a problem with the React Native code because I have tried running multiple different apps and get the same error.
Does anyone know what could be the problem and why the device and emulator aren't detected?
The problem was that my computer's antivirus had deleted adb.exe so once I reinstalled the platform tools folder containing adb.exe, react-native run-android worked as normal and my connected device was detected.

Installation did not succeed. The application could not be installed. Installation failed due to:

I am trying to run my app on Android Studio 3.5. It throws an error while installing the app on the phone.
Installation did not succeed.
The application could not be installed.
Installation failed due to: ''cmd package install-create -r -t --full -S 2164012' returns error 'Unknown failure: cmd: Failure calling service package: Failed transaction (2147483646)''
Retry
Close emulator
Wipe data in AVD Manager for a particular emulator.
Since there can be multiple reasons why it occurred, please try the following - one should work:
Execute Build > Clean project. Then, again Build > Rebuild Project.
If still the error persists, Build > Make Project
Check if Instant Run is enabled on the Android Studio. If so, disable it by navigating to:
Preferences > Build, Execution, Deployment > Instant Run
Check if the phone storage is running low. If not, uninstall the previously installed app, run adb uninstall <package_name> command from the terminal to ensure uninstalling & try installing again
Check if USB Debugging is enabled in Developer options, if not - enable it.
For Huawei devices, after executing Clean Project, navigate to Phone Manager > Cleanup and Optimize - it also worked for me on 2 Huawei devices
For Xiaomi phones, turning Off MIUI optimization has always worked for me for all Xiaomi devices. Go to Settings, find Developer Options and tap on Turn Off MIUI optimization
Please note that I was getting this error when I had emulator-5554 (minSdk(API28)) selected as the deployment target, but it went away when I changed that to Pixel_3a_API_30_x86.

adb socket not working and daemon

I am getting this type of error
error: could not install smartsocket listener: cannot bind to
127.0.0.1:5037: Only one usage of each socket address (protocol/network address/port) is normally permitted. (10048) 1:34:26
PM could not read ok from ADB Server 1:34:26 PM * failed to start
daemon * 1:34:26 PM error: cannot connect to daemon 1:34:26 PM
'C:\Users\MITESH
SUTHAR\AppData\Local\Android\Sdk\platform-tools\adb.exe,start-server'
failed -- run manually if necessary 1:38:14 PM Unable to obtain result
of 'adb version'
my genymotion device is running but it shows me that no device
I came across the same error. I provided the below command and the issue got solved.
COMMAND :- taskkill /f /im adb.exe
Close Eclipse or Android Studio if either is running (Optional).
Open Command Prompt.
Go to the Android SDK platform-tools directory.
Type adb kill-server.
Type adb start-server.
If no error message is thrown while starting ADB server, then adb is started successfully.
OR
Go to Task Manager, open the Processes tab, and end the adb.exe process.
Then restart Android Studio.
This may work if there is any problem with adb.
In my case, none of the above solution worked. I solved it strangely maybe it can be a bug.
Do not run Genymotion emulator before Android Studio. Firstly, I opened android studio then I clicked run project and select deployment target windows appeared. Then I run genymotion emulator and now the emulator is shown in the select deployment target windows in Android Studio. Then deployed to the emulator without errors. Done!
As another way, you can try to set Genymotion sdk to the same as Android studio sdk. To do this, first find your sdk location. You can find it by right clicking the Android Studio project -> Open Module Settings-> Select SDK location -> under Android SDK location, it is shown. Then open Genymotion -> Settings -> ADB tab -> Click Use custom Android SDK tools radio button -> navigate to SDK folder used by Android studio -> Restart Genymotion virtual device
If none of the above worked for you, just make sure that you have closed Genymotion emulator as it caused this issue with me.
Easiest Way! I just ran into this issue trying to connect a React-Native App to an Android Studio emulator. If you read the error message it tells you that "Only one usage of each socket address (protocol/network address/port) is normally permitted." So you can assume that something other than React-Native is also attempting to connect to the emulator.
Terminate The Connections:
Leave the emulator running.
Close out of and uninstall any Android Studio/Eclipse Apps you have on the emulator. This terminates apps trying to connect.
Close Eclipse or Android Studio if either are running. Android Studio doesn't have to be open in order for the emulator to work (This is important). This terminates software trying to connect.
After doing so I went back into my React-Native App and connected to Expo no problem.
All you have to do is terminate all connections. However you so choose.
I came across the same error, it worked simply after restarting the AS on windows, of course, it asked for SDK update.
Android Studio 4.1.3 with API 30 installation has this error
01-04-2021
09:56 'C:\Users\ranja\Android\Sdk\platform-tools\adb.exe start-server' failed -- run manually if necessary
Tried C:\Users\ranja>adb start-server
daemon not running; starting now at tcp:5037
**could not read ok from ADB Server
failed to start daemon
error: cannot connect to daemon**
Note: I have added 'C:\Users\ranja\Android\Sdk\platform-tools' in %PATH% environment variable on Windows 10
i've encountered same error in my ionic 2. i just uninstall and reinstall ionic. and it works fine again..
npm uninstall -g ionic
npm install -g ionic

cordova- adb 1.0.32 gives error "Failed to install apk to emulator" where adb1.0.31 succeeds

Running cordova emulate android gives the following error-
Error: Failed to install apk to emulator: Error executing "adb -s emulator-5554 install -r "C:/work/projects/cordova/projectName/platforms/android/build/outputs/apk/android-debug.apk"":
The error message is not actually correct because the new apk is deployed to the emulator (i have performed minor changes and the apk is updated on emulator), but the app is not started.
When I manually run the adb command that is shown in the error message i get a windows dialog saying that adb.exe has stopped responding. No error msg on the command line. Although the app on the emulator has again updated (so installation is working) and can be manually run from the emulator.
When I copy adb version 1.0.31 (exe and two dlls) over the top of version 1.0.32 in \platform-tools it all runs as expected- loads apk and starts app, no errors, regardless of whether i use cordova commands or adb command directly.
Has anyone had this issue with adb1.0.32 and or have a work solution? I have a workaround which is to use 1.0.31, but I would like to know what the issue is.

Categories

Resources