Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova and adb-server issue

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.

like image 628
Ryan Lanciaux Avatar asked Jun 17 '17 11:06

Ryan Lanciaux


4 Answers

The possible solutions for this inconsistent scenario is as follows:

  1. Add this preference in you config.xml under android platform:

    <preference name="loadUrlTimeoutValue" value="700000" />

  2. Kill and restart adb server before every launch

  3. Try creating a new AVD and mention it as target while launching the AVD

  4. Remove and re-add android platform and rebuild the same

Hope it helps.

UPDATE: preference snippet added

like image 108
Gandhi Avatar answered Nov 11 '22 08:11

Gandhi


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.

like image 29
Sebastian Avatar answered Nov 11 '22 08:11

Sebastian


Update:

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.

Original

I removed my avd device and created a new one. Additionally I updated loadUrlTimeoutValue to be a bit higher and everything started working.

like image 3
Ryan Lanciaux Avatar answered Nov 11 '22 10:11

Ryan Lanciaux


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

like image 2
Alex P. Avatar answered Nov 11 '22 08:11

Alex P.