Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
104.39k stars 10.16k forks source link

1.21 failed to execute error on Windows 7 #2838

Closed awksed closed 2 years ago

awksed commented 2 years ago

Environment

Describe the bug run scrcpy-console.bat without any params, it seems no serial was gotten. at the same time, 1.20 is working fine. any suggestion is appreciated, thx. scrcpy1 21error

scrcpy 1.21 <https://github.com/Genymobile/scrcpy>
ERROR: Failed to execute: [adb], [get-serialno]
ERROR: Could not execute "adb get-serialno"
ERROR: Could not get device serial
ERROR: Server connection failed
rom1v commented 2 years ago

What is the result of adb get-serialno if you execute manually?

Which device is it?

Which Android version?

Do yoou use another adb than the provided one?

Bonoboo commented 2 years ago

Same problem. Win7 x64, Android 11. Using provided adb adb get-serialno outputs IP and port of current wireless connection.

rom1v commented 2 years ago

I added some logs, please replace this binary in v1.21 release then post the output:

diff ```diff diff --git a/app/src/sys/win/process.c b/app/src/sys/win/process.c index bed98479..3f99dad8 100644 --- a/app/src/sys/win/process.c +++ b/app/src/sys/win/process.c @@ -46,6 +46,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, HANDLE stderr_write_handle; if (pin) { if (!CreatePipe(&stdin_read_handle, pin, &sa, 0)) { + LOGE("Create pipe stdin failed"); perror("pipe"); return SC_PROCESS_ERROR_GENERIC; } @@ -56,6 +57,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, } if (pout) { if (!CreatePipe(pout, &stdout_write_handle, &sa, 0)) { + LOGE("Create pipe stdout failed"); perror("pipe"); goto error_close_stdin; } @@ -66,6 +68,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, } if (perr) { if (!CreatePipe(perr, &stderr_write_handle, &sa, 0)) { + LOGE("Create pipe stderr failed"); perror("pipe"); goto error_close_stdout; } @@ -107,6 +110,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, InitializeProcThreadAttributeList(NULL, 1, 0, &size) || GetLastError() == ERROR_INSUFFICIENT_BUFFER; if (!ok) { + LOGE("InitializeProcThreadAttributeList failed"); goto error_close_stderr; } @@ -118,6 +122,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, ok = InitializeProcThreadAttributeList(lpAttributeList, 1, 0, &size); if (!ok) { + LOGE("InitializeProcThreadAttributeList failed"); free(lpAttributeList); goto error_close_stderr; } @@ -127,6 +132,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, handles, handle_count * sizeof(HANDLE), NULL, NULL); if (!ok) { + LOGE("UpdateProcThreadAttribute failed"); goto error_free_attribute_list; } @@ -154,6 +160,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, dwCreationFlags, NULL, NULL, &si.StartupInfo, &pi); free(wide); if (!ok) { + LOGE("CreateProcessW failed"); if (GetLastError() == ERROR_FILE_NOT_FOUND) { ret = SC_PROCESS_ERROR_MISSING_BINARY; } ```
Bonoboo commented 2 years ago

Here you are. P.S. Huge thanks for this awesome software.

scrcpy 1.21 <https://github.com/Genymobile/scrcpy>
ERROR: CreateProcessW failed
ERROR: Failed to execute: [adb], [get-serialno]
ERROR: Could not execute "adb get-serialno"
ERROR: Could not get device serial
ERROR: Server connection failed
rom1v commented 2 years ago

Thank you. I forgot to print the error code. Could you do the same with this one, please:

diff ```diff diff --git a/app/src/sys/win/process.c b/app/src/sys/win/process.c index bed98479..6ed9cb0d 100644 --- a/app/src/sys/win/process.c +++ b/app/src/sys/win/process.c @@ -46,6 +46,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, HANDLE stderr_write_handle; if (pin) { if (!CreatePipe(&stdin_read_handle, pin, &sa, 0)) { + LOGE("Create pipe stdin failed"); perror("pipe"); return SC_PROCESS_ERROR_GENERIC; } @@ -56,6 +57,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, } if (pout) { if (!CreatePipe(pout, &stdout_write_handle, &sa, 0)) { + LOGE("Create pipe stdout failed"); perror("pipe"); goto error_close_stdin; } @@ -66,6 +68,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, } if (perr) { if (!CreatePipe(perr, &stderr_write_handle, &sa, 0)) { + LOGE("Create pipe stderr failed"); perror("pipe"); goto error_close_stdout; } @@ -107,6 +110,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, InitializeProcThreadAttributeList(NULL, 1, 0, &size) || GetLastError() == ERROR_INSUFFICIENT_BUFFER; if (!ok) { + LOGE("InitializeProcThreadAttributeList failed"); goto error_close_stderr; } @@ -118,6 +122,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, ok = InitializeProcThreadAttributeList(lpAttributeList, 1, 0, &size); if (!ok) { + LOGE("InitializeProcThreadAttributeList failed"); free(lpAttributeList); goto error_close_stderr; } @@ -127,6 +132,7 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, handles, handle_count * sizeof(HANDLE), NULL, NULL); if (!ok) { + LOGE("UpdateProcThreadAttribute failed"); goto error_free_attribute_list; } @@ -154,7 +160,9 @@ sc_process_execute_p(const char *const argv[], HANDLE *handle, unsigned flags, dwCreationFlags, NULL, NULL, &si.StartupInfo, &pi); free(wide); if (!ok) { - if (GetLastError() == ERROR_FILE_NOT_FOUND) { + int err = GetLastError(); + LOGE("CreateProcessW failed: %d", err); + if (err == ERROR_FILE_NOT_FOUND) { ret = SC_PROCESS_ERROR_MISSING_BINARY; } goto error_free_attribute_list; ```
awksed commented 2 years ago

What is the result of adb get-serialno if you execute manually?

Which device is it?

Which Android version?

Do yoou use another adb than the provided one?

Hi Rom, It's Mi mobile phone, with Android 11. I didn't set other adb.exe, I directly run the bat file so i think it is using its own adb.
scrcpy1 21error

Bonoboo commented 2 years ago
scrcpy 1.21 <https://github.com/Genymobile/scrcpy>
ERROR: CreateProcessW failed: 1450
ERROR: Failed to execute: [adb], [get-serialno]
ERROR: Could not execute "adb get-serialno"
ERROR: Could not get device serial
ERROR: Server connection failed
rom1v commented 2 years ago

ERROR: CreateProcessW failed: 1450

https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1300-1699-

ERROR_NO_SYSTEM_RESOURCES 1450 (0x5AA) Insufficient system resources exist to complete the requested service

:thinking:

rom1v commented 2 years ago

This is a Windows 7 specific problem it seems: https://bugzilla.mozilla.org/show_bug.cgi?id=1460995

awksed commented 2 years ago

scrcpy 1.21 https://github.com/Genymobile/scrcpy ERROR: CreateProcessW failed: 1450 ERROR: Failed to execute: [adb], [get-serialno] ERROR: Could not execute "adb get-serialno" ERROR: Could not get device serial ERROR: Server connection failed

after replaced the scrcpy.exe, output is above messages. besides, I built the source code 1.21 in ubuntu and it DO run correctly in ubuntu. I'm tring to built it to Win64 in ubuntu, but haven't finished yet due to the built environment of Win needs to be set.

Bonoboo commented 2 years ago

I'm not code expert, but maybe some of this commits cause bug?

rom1v commented 2 years ago

More probably 9cb14b51663d61c6f0b41da3c5699de418d633aa or f801d8b3128cf5aae3725c981f32abfd4b6c307e.

rom1v commented 2 years ago

Could you please test this one?

Bonoboo commented 2 years ago

It works, thanks.

rom1v commented 2 years ago

I submitted a PR (#2840) and referenced it from the release page.

I probably won't publish a new (minor) version just for this (it would increment the version for everyone, whereas only Windows 7 is impacted), I will wait more changes (or at least a few days or more). Windows 7 users could just download the binary from #2840 :wink:

FinlayDaG33k commented 2 years ago

Could you please test this one?

  • scrcpy.exe sha256:8c41744d76ba9003d4a5e5ac7c0e4d42bc136349076b4db099888fdc06f0bb5a

I ran into a similar issue, which would also be solved by this patch.

scrcpy 1.21 <https://github.com/Genymobile/scrcpy>
ERROR: Failed to execute: [adb], [-s], [5e0ed092], [push], ["J:\Toolkit\srcrpy\bin\scrcpy\scrcpy-server"], ["/data/local/tmp/scrcpy-server.jar"]
ERROR: Could not execute "adb push"
ERROR: Server connection failed
guadeifel commented 2 years ago

I have the same issue, but on Windows 11 x64. Android 11. When I run as administrator, nothing happens, it just run very quickly and close automatic. But when I just run scrcpy, this message shows:

scrcpy 1.21 https://github.com/Genymobile/scrcpy ERROR: CreateProcessW() error 5 ERROR: Failed to execute: [C:\Users\gusta\AppData\Local\Android\Sdk\platform-tools], [get-serialno] ERROR: Could not execute "adb get-serialno" ERROR: Could not get device serial ERROR: Server connection failed

Leuhan77 commented 2 years ago

Could you please test this one?

  • scrcpy.exe sha256:8c41744d76ba9003d4a5e5ac7c0e4d42bc136349076b4db099888fdc06f0bb5a

for windows 7 32 bits?

awksed commented 2 years ago

I submitted a PR (#2840) and referenced it from the release page.

I probably won't publish a new (minor) version just for this (it would increment the version for everyone, whereas only Windows 7 is impacted), I will wait more changes (or at least a few days or more). Windows 7 users could just download the binary from #2840 wink

it works. thks!

rom1v commented 2 years ago

@guadeifel Your problem is different:

ERROR: Failed to execute: [C:\Users\gusta\AppData\Local\Android\Sdk\platform-tools], [get-serialno]

You set the ADB environment variable to a wrong value: it must point to the adb.exe executable, not its directory (C:\Users\gusta\AppData\Local\Android\Sdk\platform-tools\adb.exe).

rom1v commented 2 years ago

for windows 7 32 bits?

I just updated #2840 with a link to a 32 bits version.

Leuhan77 commented 2 years ago

para windows 7 32 bits?

Acabo de actualizar # 2840 con un enlace a una versión de 32 bits.

Thanks

guadeifel commented 2 years ago

@guadeifel Your problem is different:

ERROR: Failed to execute: [C:\Users\gusta\AppData\Local\Android\Sdk\platform-tools], [get-serialno]

You set the ADB environment variable to a wrong value: it must point to the adb.exe executable, not its directory (C:\Users\gusta\AppData\Local\Android\Sdk\platform-tools\adb.exe).

Thanks for the answer @rom1v, I made this change. After that, I just turns off and on the permission USB Debugging, and works. 🤘🏻

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 2 years ago

I started getting similar error since 1.21 when running from cygwin on windows 11 (it worked fine until now):

$ scrcpy scrcpy 1.21 https://github.com/Genymobile/scrcpy ERROR: Failed to execute: [adb], [-s], [:5555], [push], ["C:\path\to\scrcpy-win64\scrcpy-server"], ["/data/local/tmp/scrcpy-server.jar"] ERROR: Could not execute "adb push" ERROR: Server connection failed

$ adb get-serialno

:5555 ----------- this is ok ################# On 1.20 (working) output was: $ scrcpy INFO: scrcpy 1.20 C:\path\to\scrcpy-win64\scrcpy-server: 1 file pushed, 0 skipped. 40.6 MB/s (37139 bytes in 0.001s) [server] INFO: Device: (Android XX) INFO: Renderer: direct3d INFO: Initial texture: 1440x3120
rom1v commented 2 years ago

@fusionneur Did you read the issue and the answers of this thread? In short, see #2840.

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 2 years ago

Yes, get to the point. I just wanted to share my experience even if it is not related to Win 7, but the error is similar.

EDIT: I am running windows 11

rom1v commented 2 years ago

@fusionneur Oh ok, I didn't understand that it was not on Windows 7. Does #2840 (or dev branch) also fix the problem for you?

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 2 years ago

yes, overwriting scrpcy.exe with the one from #2840 makes it work again under Win 11 via cygwin

huy-ffd commented 2 years ago

For Windows 10 via cygwin, overwriting scrcpy.exe with the one from #2840 like fusionneur said also fixed this problem for me. It doesn't only happen on Windows 7 or Windows 11.

dragongyke commented 2 years ago

Hi, I got a similar issue, after overwriting with #2840 scrcpy.exe, I got the following result.

C:\Tools\scrcpy-win64-v1.21>scrcpy.exe scrcpy 1.21 https://github.com/Genymobile/scrcpy ERROR: CreateProcessW() error 5 ERROR: Failed to execute: [C:\Android\SDK\platform-tools], [get-serialno] ERROR: Could not execute "adb get-serialno" ERROR: Could not get device serial ERROR: Server connection failed

C:\Tools\scrcpy-win64-v1.21>adb get-serialno PA7F40OGE8290158B

rom1v commented 2 years ago

@dragongyke https://github.com/Genymobile/scrcpy/issues/2838#issuecomment-983331810

dragongyke commented 2 years ago

@rom1v Thank you very much. But if I set my system environment parameter for ADB to C:\Android\SDK\platform-tools\adb.exe, the global ADB will not work any more. Seems scrcpy will use the one within its same folder. So the issue now is either the global ADB can work (with the value of "C:\Android\SDK\platform-tools\"), or the Scrcpy can work.

rom1v commented 2 years ago

But if I set my system environment parameter for ADB to C:\Android\SDK\platform-tools\adb.exe, [...] Seems scrcpy will use the one within its same folder.

No, it will use the one you provide in ADB.

gabszap commented 2 years ago

Hi, I got a similar issue, after overwriting with #2840 scrcpy.exe, I got the following result.

scrcpy 1.21 https://github.com/Genymobile/scrcpy C:\Users\Gabriel\Downloads\scrcpy-win3...ped. 33.9 MB/s (40067 bytes in 0.001s) [server] INFO: Device: samsung SM-A325M (Android 11) [server] ERROR: Exception on thread Thread[main,5,main] java.lang.IllegalStateException at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method) at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:3452) at com.genymobile.scrcpy.ScreenEncoder.encode(ScreenEncoder.java:110) at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncode r.java:91) at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:6 5) at com.genymobile.scrcpy.Server.scrcpy(Server.java:93) at com.genymobile.scrcpy.Server.main(Server.java:309) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:409) INFO: Renderer: direct3d INFO: Initial texture: 1080x2400 WARN: Device disconnected WARN: Killing the server...

OS: Windows 7 32 bits

Edit: solved.

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 2 years ago

how you solved it?

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 2 years ago

i am getting disconnections when locking/unlocking phone with the replaced exe

rom1v commented 2 years ago

@Gabriel4927 https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#exception

i am getting disconnections when locking/unlocking phone

@fusionneur #597

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 2 years ago

Thank you @rom1v that fixed it for me. I wrote more details on #597

gabszap commented 2 years ago

how you solved it?

Decreasing quality, the program doesn't accept the full quality of the screen

gurvinderbini commented 2 years ago

Can anyone help me with this? I am using windows 11

scrcpy 1.23 https://github.com/Genymobile/scrcpy ERROR: CreateProcessW() error 2 ERROR: Command not found: [C:\Program Files (x86)\Android\android-sdk\platform-tools], [start-server] ERROR: (make 'adb' accessible from your PATH or define its fullpath in the ADB environment variable) ERROR: Could not execute "adb start-server" ERROR: Could not start adb daemon ERROR: Server connection failed Press any key to continue . . .

rom1v commented 2 years ago

ERROR: Command not found: [C:\Program Files (x86)\Android\android-sdk\platform-tools], [start-server]

You set the ADB environment to a wrong value (it must point to the adb.exe executable, not its parent directory).

But you should remove this environment variable unless you absolutely need to use a custom adb.

Neutx commented 1 year ago

It was running perfectly until one day I get this issue:

D:>scrcpy scrcpy 1.24 https://github.com/Genymobile/scrcpy ERROR: CreateProcessW() error 193 ERROR: Failed to execute: [C:\Users\Adil Parwez\Desktop\scrcpy\adb.exe], [start-server] ERROR: Could not execute "adb start-server" ERROR: Could not start adb daemon ERROR: Server connection failed

rom1v commented 1 year ago

Can you execute C:\Users\Adil Parwez\Desktop\scrcpy\adb.exe?