Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.21 failed to execute error on Windows 7 #2838

Closed
awksed opened this issue Nov 30, 2021 · 43 comments
Closed

1.21 failed to execute error on Windows 7 #2838

awksed opened this issue Nov 30, 2021 · 43 comments

Comments

@awksed
Copy link

awksed commented Nov 30, 2021

  • [ Y] I have read the FAQ.
  • [Y ] I have searched in existing issues.

Environment

  • OS: WIN7 64
  • scrcpy version: 1.21
  • installation method: release
  • device model:
  • Android version: [e.g. 10]

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
Copy link
Collaborator

rom1v commented Nov 30, 2021

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
Copy link

Bonoboo commented Nov 30, 2021

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

@rom1v
Copy link
Collaborator

rom1v commented Nov 30, 2021

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

  • scrcpy.exe sha256:de91898be9e946cac473e4f9c5ed5f29280851c8a162d7c1c151e01c4b8608d1
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
Copy link

Bonoboo commented Nov 30, 2021

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
Copy link
Collaborator

rom1v commented Nov 30, 2021

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

  • scrcpy.exe _sha256:fedf4b7afa2e214fda1268c05d08554d7e7dac15e206ce559aae83272aaa607b
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
Copy link
Author

awksed commented Nov 30, 2021

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
Copy link

Bonoboo commented Nov 30, 2021

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
Copy link
Collaborator

rom1v commented Nov 30, 2021

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

🤔

@rom1v
Copy link
Collaborator

rom1v commented Nov 30, 2021

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

@awksed
Copy link
Author

awksed commented Nov 30, 2021

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.

rom1v added a commit that referenced this issue Nov 30, 2021
@Bonoboo
Copy link

Bonoboo commented Nov 30, 2021

@rom1v
Copy link
Collaborator

rom1v commented Nov 30, 2021

More probably 9cb14b5 or f801d8b.

@rom1v rom1v changed the title 1.21 failed to execute error. 1.21 failed to execute error on Windows 7 Nov 30, 2021
@rom1v
Copy link
Collaborator

rom1v commented Nov 30, 2021

Could you please test this one?

  • scrcpy.exe sha256:8c41744d76ba9003d4a5e5ac7c0e4d42bc136349076b4db099888fdc06f0bb5a

@Bonoboo
Copy link

Bonoboo commented Nov 30, 2021

It works, thanks.

rom1v added a commit that referenced this issue Nov 30, 2021
According to this bug report on Firefox:
<https://bugzilla.mozilla.org/show_bug.cgi?id=1460995>

> CreateProcess fails with ERROR_NO_SYSTEM_RESOURCES on Windows 7. It
> looks like the reason why is because PROC_THREAD_ATTRIBUTE_HANDLE_LIST
> doesn't like console handles.

To avoid the problem, do not pass console handles to
PROC_THREAD_ATTRIBUTE_HANDLE_LIST.

Refs #2783 <#2783>
Refs f801d8b
Fixes #2838 <#2838>
@rom1v
Copy link
Collaborator

rom1v commented Nov 30, 2021

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 😉

@FinlayDaG33k
Copy link

FinlayDaG33k commented Nov 30, 2021

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
Copy link

guadeifel commented Dec 1, 2021

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
Copy link

Leuhan77 commented Dec 1, 2021

Could you please test this one?

  • scrcpy.exe sha256:8c41744d76ba9003d4a5e5ac7c0e4d42bc136349076b4db099888fdc06f0bb5a

for windows 7 32 bits?

@awksed
Copy link
Author

awksed commented Dec 1, 2021

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
Copy link
Collaborator

rom1v commented Dec 1, 2021

@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
Copy link
Collaborator

rom1v commented Dec 1, 2021

for windows 7 32 bits?

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

@Leuhan77
Copy link

Leuhan77 commented Dec 1, 2021

para windows 7 32 bits?

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

Thanks

@guadeifel
Copy link

@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
Copy link

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented Dec 4, 2021

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], [<my_device_IP>: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
<my_device_IP>:5555 ----------- this is ok

#################

On 1.20 (working) output was:

$ scrcpy
INFO: scrcpy 1.20 https://github.com/Genymobile/scrcpy
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
Copy link
Collaborator

rom1v commented Dec 4, 2021

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

@Uj947nXmRqV2nRaWshKtHzTvckUUpD
Copy link

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented Dec 4, 2021

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
Copy link
Collaborator

rom1v commented Dec 4, 2021

@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

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

@huy-ffd
Copy link

huy-ffd commented Dec 7, 2021

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
Copy link

dragongyke commented Dec 14, 2021

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
Copy link
Collaborator

rom1v commented Dec 14, 2021

@dragongyke
Copy link

@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
Copy link
Collaborator

rom1v commented Dec 16, 2021

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
Copy link

gabszap commented Jan 6, 2022

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

how you solved it?

@Uj947nXmRqV2nRaWshKtHzTvckUUpD

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

@rom1v
Copy link
Collaborator

rom1v commented Jan 7, 2022

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

i am getting disconnections when locking/unlocking phone

@fusionneur #597

@Uj947nXmRqV2nRaWshKtHzTvckUUpD

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

@gabszap
Copy link

gabszap commented Jan 8, 2022

how you solved it?

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

@gurvinderbini
Copy link

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
Copy link
Collaborator

rom1v commented Apr 26, 2022

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
Copy link

Neutx commented Dec 8, 2022

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
Copy link
Collaborator

rom1v commented Dec 9, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests