I'm building a project with Cordova. On iOS, the workflow seems about what I was expecting but on Android it's quite the balancing act and I'm not entirely sure how to fix. Initially, I receive the following error when running cordova run android ...
:
Error: Failed to execute shell command "getprop,dev.bootcomplete"" on device: Error: adb: Command failed with exit code 1 Error output:
error: device unauthorized.
From here, I run adb-kill server
and run cordova run android ...
again. The emulator and application appear to launch without the previous adb issues, however, after showing the splash screen, the application crashes with the following error dialog in the Android emulator:
Application Error
The connection to the server was unsuccessful.
(file:///android_asset/www/index.html)
If I run cordova run android ...
one more time the application loads successfully and I can run through the application as expected. If I reboot, I need to start this process all over again. This application works on other people's computers so I imagine there is something misconfigured on my system but I'm not sure the best way to proceed determining what is wrong.
The possible solutions for this inconsistent scenario is as follows:
Add this preference in you config.xml under android platform:
<preference name="loadUrlTimeoutValue" value="700000" />
Kill and restart adb server before every launch
Try creating a new AVD and mention it as target while launching the AVD
Remove and re-add android platform and rebuild the same
Hope it helps.
UPDATE: preference snippet added
I am facing the same problem.
Sometimes it helps to run:
adb kill-server
adb forward --remove-all
adb start-server
However, I still have to run this from time to time and it can't be the perfect solution.
This doesn't seem to be the answer - upon some more time, I'm still receiving
Error: Failed to execute shell command "getprop,dev.bootcomplete"" on device: Error: adb: Command failed with exit code 1 Error output:
error: device unauthorized.
I removed my avd device and created a new one. Additionally I updated loadUrlTimeoutValue
to be a bit higher and everything started working.
You are obviously experiencing a race condition where adb
device is already enumerated/connected but not yet authorized. You could either wait for cordova
to fix their code to eliminate the race condition altogether (or maybe even do it yourself) or just use userdebug
(or eng
) Android image with ro.adb.secure=0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With