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

Scrcpy issue on MacOS #190

Closed
shailantani opened this issue Apr 10, 2024 · 29 comments
Closed

Scrcpy issue on MacOS #190

shailantani opened this issue Apr 10, 2024 · 29 comments
Labels
need more info Further information is requested

Comments

@shailantani
Copy link

Hi I'm trying to use the scrcpy option on macOS, but it opens the terminal and just doesnt work.
I've set the scrcpy path as well, which is "/opt/homebrew/Cellar/scrcpy/2.4/bin/scrcpy"
I've set the same path in PixelFlasher as well. But when I click on the scrcpy option, the terminal opens with this error:

I'm using the PixelFlasher 6.9.1.3 version

Screenshot 2024-04-10 at 6 40 21 PM


Screenshot 2024-04-10 at 6 41 15 PM


Screenshot 2024-04-10 at 6 41 47 PM
@badabing2005
Copy link
Owner

Can you Open ADB Shell with PixelFlasher? and does that work?
See details in ticket #185, you might have the same issue not allowing PixelFlasher access to Terminal.

@shailantani
Copy link
Author

Yeah, so when I click on the adb shell, terminal opens up and i think its working too. (Added screenshot)
And I confirmed that I had given Terminal access to PixelFlasher too. Anything else I could do perhaps?


Screenshot 2024-04-10 at 9 34 22 PM

@badabing2005
Copy link
Owner

Could you enable debug logging and try again so the events are captured in the log, and then provide support.zip?
Hoping I could spot something in there.
@knutlegrand does scrcpy work for you?
Trying to see if this is a common MacOS issue or an isolated issue.

Thanks

@badabing2005 badabing2005 added the need more info Further information is requested label Apr 11, 2024
@knutlegrand
Copy link

Not working (same as first post of this thread). ADB option is still working well
Here is the support file (debug activated).
Hope this helps.
support_2024-04-11_10-00-37.zip

@shailantani
Copy link
Author

Here's mine:
support_2024-04-11_13-41-47.zip

@badabing2005 badabing2005 added bug Something isn't working and removed need more info Further information is requested labels Apr 11, 2024
@badabing2005
Copy link
Owner

Not working (same as first post of this thread). ADB option is still working well Here is the support file (debug activated). Hope this helps. support_2024-04-11_10-00-37.zip

Thanks, I see that you set the path to:

Setting scrcpy path path to: /usr/local/Cellar/scrcpy/2.4_1/bin

PF attempted to run

Launching scrcpy for device: REDACTED ...
debug: "/usr/local/Cellar/scrcpy/2.4_1/bin" -s REDACTED

Which would not work as that is not the full path to scrcpy, it needs to include the scrcpy executable.

Please try setting to:

/usr/local/Cellar/scrcpy/2.4_1/bin/scrcpy

And test again
If it still fails, can you try this command from terminal?

/usr/local/Cellar/scrcpy/2.4_1/bin/scrcpy" -s REDACTED

Replace REDACTED with your device id.

@shailantani
Yours is setup correctly.
PixelFlasher tried to launch

"/opt/homebrew/Cellar/scrcpy/2.4/bin/scrcpy" -s 10.10.30.54:5555

Can you please try that from terminal and see if it works?

Sorry, not having a Mac impedes my ability to provide quicker resolution and have to rely on your feedback.
Hackintosh has its limitations.

Thanks

@knutlegrand
Copy link

Please try setting to:

/usr/local/Cellar/scrcpy/2.4_1/bin/scrcpy

--> Done, scrcpy option works now

@badabing2005
Copy link
Owner

Thanks @knutlegrand

@shailantani I'll wait for your feedback, we know the feature works, something must be different on yours.

@badabing2005 badabing2005 added need more info Further information is requested and removed bug Something isn't working labels Apr 11, 2024
@shailantani
Copy link
Author

Hi sorry for the delay, so running the command on terminal works
"/opt/homebrew/Cellar/scrcpy/2.4/bin/scrcpy" -s 10.10.30.54:5555
But again, through pixel flasher it doesnt for some reason.
Anything I can do to help you further debug it?

@badabing2005
Copy link
Owner

badabing2005 commented Apr 11, 2024

PixelFlasher first dynamically creats a script in system temp directory with the following content.
let's call it temp.sh for this exacmple

"/opt/homebrew/Cellar/scrcpy/2.4/bin/scrcpy" -s 10.10.30.54:5555

This is based on the defined path of scrcpy and the connected / selected device.

Then it launches the following command:
For this example, I'm assuming that you create the temp.sh in your home directory

osascript -e tell application "Terminal" to do script "~temp.sh"

Can you create the temp.sh and launch and type the osascript command in terminal and see if it works for you please?

Thanks

@shailantani
Copy link
Author

Hi so I added a temp.sh file and ran the code. Heres the errors:
Screenshot 2024-04-12 at 10 22 33 AM
Above is the temp.sh file

And then heres what I had inputted in the terminal:
Screenshot 2024-04-12 at 10 21 50 AM

So the first command was connecting the adb device and it was connected.
Second command was the one that you had asked me to input, which popped up an error.
In the third command, I tried specifying the location of the temp.sh too, but that too popped up an error.

Am I doing something wrong?
Thanks!

@badabing2005
Copy link
Owner

try

chmod 755 ~/temp.sh

see if this works

~/.temp.sh

and then this

osascript -e tell application "Terminal" to do script "~temp.sh"

@shailantani
Copy link
Author

Okay so, I did the chmod 755 ~/temp.sh and it woked.
Then I tried the ~/.temp.sh and the scrcpy worked, the the phone screen was shown.
But upon trying osascript -e tell application "Terminal" to do script "~temp.sh" an error popped up. Heres the screenshot:
What can I do now?


Screenshot 2024-04-13 at 10 35 36 AM

Thanks!

@shailantani
Copy link
Author

shailantani commented Apr 13, 2024

OHHHH Interesting, So I searched a bit more about the error and there has to be a change in the code:

It should be:

osascript -e 'tell application "Terminal" to do script "/Users/shailantani/temp.sh "'
instead of:

osascript -e tell application "Terminal" to do script "~temp.sh"

So there were 2 changes I made:

  1. Adding quotes before 'tell' and after 'temp.sh'
  2. Properly specifying the location of temp.sh ie "/Users/shailantani/temp.sh " instead of ~temp.sh

Please do check it out once, Thanks. And let me know if further information is required!
@badabing2005

@badabing2005
Copy link
Owner

badabing2005 commented Apr 14, 2024

OHHHH Interesting, So I searched a bit more about the error and there has to be a change in the code:

It should be:

osascript -e 'tell application "Terminal" to do script "/Users/shailantani/temp.sh "' instead of:

osascript -e tell application "Terminal" to do script "~temp.sh"

So there were 2 changes I made:

1. Adding quotes before 'tell' and after 'temp.sh'

2. Properly specifying the location of temp.sh ie `"/Users/shailantani/temp.sh "` instead of `~temp.sh`

Please do check it out once, Thanks. And let me know if further information is required! @badabing2005

Thanks for the investigation.
I'll make the necessary changes, although it is surprising that it doesn't work for scrcpy but works for adb shell and for @knutlegrand it works as is for both.

By the way point 2 is non-issue as PF always specifies full path.

badabing2005 added a commit that referenced this issue Apr 14, 2024
…ntially switch from Beta to Stable without a wipe.

  Credit to @tbalden for the discovery and @capntrips for the details of the process.
- Select any img file and get additional image info.
- #190 fix, scrcpy launch improvement.
- Improved Menu to disabled advanced features when it's not enabled in the settings. (Previously only other GUI elements were hidden or disabled).
- If KernelSU or APatch is installed, report their version as part of device details.
- Improved logging.
- Improved santization.
- Other minor improvements and added stability.
@badabing2005
Copy link
Owner

@shailantani
Please give this version a try.
https://github.com/badabing2005/PixelFlasher/releases/tag/v6.9.2.0

@shailantani
Copy link
Author

@shailantani Please give this version a try. https://github.com/badabing2005/PixelFlasher/releases/tag/v6.9.2.0

Hi, so I just tried that version. The scrcpy works, but "adb" stopped working now 😭
This is the error:



Screenshot 2024-04-15 at 2 07 42 PM

Heres the support file:
support_2024-04-15_14-08-32.zip

@badabing2005
Copy link
Owner

I'm fed up with Apple shenanigans.
See here and here

Identical code, one to launch the adb shell the other to launch scrcpy.
And now adb shell doesn't want to work with single quotes around tell?

I'm not touching this until I hear from @knutlegrand or others if this is common issue for all.
I might revert to the previous way if the older version works for all others but not you.
I'm sorry but I'd like to keep things consistent and determininstic.

@knutlegrand
Copy link

Have checked both versions

  • scrcpy not OK , adb OK in 6.9.1.3
  • scrcpy OK , adb not OK in 6.9.2.1

Why not using these commands ?

  • adb : subprocess.run(['/Users/REDACTED/Library/Android/sdk/platform-tools/adb', '-s', '3B071JEHN10437', 'shell'])
  • scrcpy : subprocess.run(['/usr/local/Cellar/scrcpy/2.4_1/bin/scrcpy', '-s', '3B071JEHN10437' ])

This might avoid the creation/deletion of a temporary script.
Maybe it's worth a try.

Anyway, it's quite easy to launch adb & scrcpy directly from the terminal. I would say that there is definitely no need to waste too much time on this.

@badabing2005
Copy link
Owner

That's exactly how it is done, on Linux and Windows,
But Apple being Apple, it has to be different and complicated ;)
That method does not work on Apple, at least didn't when I first added the feature.

@badabing2005
Copy link
Owner

Please try this version.
I reverted the way ADB Shell is launched.
https://github.com/badabing2005/PixelFlasher/actions/runs/8692363043

@knutlegrand
Copy link

Both options are working on the same PF version ! Good job

@badabing2005
Copy link
Owner

Thank you.

@shailantani
Copy link
Author

Please try this version. I reverted the way ADB Shell is launched. https://github.com/badabing2005/PixelFlasher/actions/runs/8692363043

Hi I'm sorry but could you tell me how I can run the app from the actions?
When I download the PixelFlasher.app, it gets downloaded as zip. Do I extract it then and run it?

Sorry for the doubt :")

@badabing2005
Copy link
Owner

@shailantani
I'm not a Mac user, but I think you just remove the .zip extension and drag it to your applications folder.

@knutlegrand
Copy link

knutlegrand commented Apr 16, 2024

You

@shailantani I'm not a Mac user, but I think you just remove the .zip extension and drag it to your applications folder.

@shailantani No, You have to unzip it, then you get "Contents" folder. Within this folder, navigate to folder MacOS.
There, you'll find PixelFlasher file.

In terminal, enter following commands:

  • cd path_to_unzipped_Contents_folder/MacOS
  • chmod +x PixelFlasher (making it executable)
  • mv PixelFlasher file to [path_to_PixelFlasher.app]/Contents/MacOS folder file (PixelFlasher.app is normally located in Applications folder)

@shailantani
Copy link
Author

You

@shailantani I'm not a Mac user, but I think you just remove the .zip extension and drag it to your applications folder.

@shailantani No, You have to unzip it, then you get "Contents" folder. Within this folder, navigate to folder MacOS. There, you'll find PixelFlaxer file.

In terminal, enter following commands:

  • cd path_to_unzipped_Contents_folder/MacOS
  • chmod +x PixelFlasher (making it executable)
  • mv PixelFlasher file to [path_to_PixelFlasher.app]/Contents/MacOS folder file (PixelFlasher.app is normally located in Applications folder)

Awesome, will try it out. Thank you so much for the help 👍

@shailantani
Copy link
Author

Please try this version. I reverted the way ADB Shell is launched. https://github.com/badabing2005/PixelFlasher/actions/runs/8692363043

@badabing2005
Finally this version seems to be working with both adb and scrcpy 😄
Amazing job!!

@knutlegrand Thanks a lot for all the help btw!

badabing2005 added a commit that referenced this issue Apr 17, 2024
- Logging improvements
- When Magisk delta is installed, automatically set the package to: `io.github.huskydg.magisk`
@roryokane
Copy link

Please try this version. I reverted the way ADB Shell is launched.
https://github.com/badabing2005/PixelFlasher/actions/runs/8692363043

Hi I'm sorry but could you tell me how I can run the app from the actions?
When I download the PixelFlasher.app, it gets downloaded as zip. Do I extract it then and run it?

For future reference, here is my method for testing PixelFlasher.app.zip files downloaded from GitHub Actions on macOS. This method should make testing a little more accurate than @knutlegrand’s method. To help anyone unfamiliar with Terminal, I wrote the steps in more detail, too.

  1. Open “PixelFlasher.app.zip”. This will unarchive it, creating a “Contents” folder as a sibling.
  2. In Finder, navigate inside Contents/MacOS/ so you can see the PixelFlasher file.
  3. Open Terminal (in /Applications/Utilities/). Type chmod +x (with the ending space), then drag and drop the PixelFlasher file onto the Terminal window. Press Return to run the command. (This gives PixelFlasher executable permissions.)
  4. In Finder, navigate back up (for example, hit ⌘↑ twice) until you can see the “Contents” folder next to the zip file. Copy the text “PixelFlasher.app” to make the next step easier.
    • To copy this, I find it convenient to select the “PixelFlasher.app.zip” file in Finder, hit Return to select the basename “PixelFlasher.app”, then Copy (⌘C).
  5. Select the “Contents” folder and use menu item File > New Folder with “Contents” (⌃⌘N) to wrap it in an enclosing folder. When Finder prompts you to rename “New Folder With Items”, paste “PixelFlasher.app” as the name.

This produces a new copy of the PixelFlasher app completely derived from the zip file. While testing, you can run this app where it is – you don’t need to overwrite your existing /Applications/PixelFlasher.app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants