Skip to content

build(android): support android platform (config and logging) #3741

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

Merged
merged 8 commits into from
Jul 14, 2025

Conversation

mengyanshou
Copy link
Contributor

@mengyanshou mengyanshou commented Mar 21, 2025

Description

Adapt config and logging for Android:

  • Add macro definitions to ensure successful compilation.
  • Add a custom Boost backend for Android to ensure proper functionality.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Copy link
Member

@ReenigneArcher ReenigneArcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! I'm looking forward to this.

I expected more changes for in order for initial Android support. Is there more coming? Maybe something in the ./cmake directory?

mengyanshou and others added 3 commits March 23, 2025 19:13
LGTM

Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com>
LGTM

Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com>
@mengyanshou
Copy link
Contributor Author

Sorry for the delayed response. Unfortunately, I don't have much time either.

My main tech stack is Flutter (UI Framework) and Android Native.

Typically, the compilation of an Android app differs significantly from C/C++ and requires the Java environment and Gradle.

So, from my current perspective, it seems quite difficult to make the Sunshine workflow directly produce an APK.

Additionally, I'm concerned that my lack of proficiency in C/C++ might disrupt the original workflow, so I plan to submit PRs in multiple stages.

However, I can start with some compilation adaptations to ensure that future Sunshine APKs for Android can be imported and compiled smoothly.

As seen in the patches, I can now directly use the Sunshine Source along with a Patch Script to make Android compilation work properly.

My initial idea is to submit these patches to Sunshine so that the Android-compiled Sunshine and the Sunshine source code can remain consistent.

Additionally, I’d like to share some recent comparisons with scrcpy.

I’ve studied a lot of scrcpy’s code. In fact, scrcpy is already very efficient. It’s possible that the client’s use of SDL2 results in rendering that’s not as extremely efficient (just a guess). However, in terms of the server side, scrcpy and the ported Sunshine for Android should be roughly the same.

That said, porting to Android still has significant value because it allows users to use Moonlight to stream their Android devices.

I will continue to push this process forward.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@ReenigneArcher ReenigneArcher changed the title build(android): support android platform build(android): support android platform (config and logging) Mar 24, 2025
@ReenigneArcher ReenigneArcher added the question Further information is requested label Apr 4, 2025
@LizardByte-bot
Copy link
Member

It looks like this PR has been idle for 90 days. If it's still something you're working on or would like to pursue, please leave a comment or update your branch. Otherwise, we'll be closing this PR in 10 days to reduce our backlog. Thanks!

@mengyanshou
Copy link
Contributor Author

I've been too busy recently and have no idea how to move this PR forward. I used to open it occasionally, but there has been no progress on the parts awaiting review. So I haven't paid much attention to it since then.

@ReenigneArcher
Copy link
Member

@mengyanshou there's a few comments above that haven't been addressed yet. I'd be happy to discuss in discord if there is some confusion to clear up?

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@ReenigneArcher

This comment was marked as resolved.

@mengyanshou
Copy link
Contributor Author

Sorry, my hand was shaking and I clicked the wrong one. But I think most of them should be the reviews waiting for a reply on my side. If these changes are accepted, I will modify these reviews as resolved to proceed with the subsequent merge.

Then regarding one of the Todos, I currently don't know how to implement it, but I think it's necessary to keep the todo.

截屏2025-07-13 00 51 53

@ReenigneArcher
Copy link
Member

Don't worry about the TODO warning, those are okay.

Copy link
Contributor Author

@mengyanshou mengyanshou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good to me!

@mengyanshou
Copy link
Contributor Author

Next, what can I do to help move forward? I have very little time recently and should not be able to continue submitting changes to the code until next month. Then, thank you for your cooperation @ReenigneArcher

Copy link
Member

@ReenigneArcher ReenigneArcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems pretty good to me. In addition to my one question below, I have one more. If possible @FrogTheFrog, could you check the updated logging section?

What would it take to compile this in our CI (understanding no apk would be provided yet)? Could you provide instructions either here or in https://github.com/LizardByte/Sunshine/blob/master/docs/building.md

@@ -1038,9 +1038,12 @@ namespace config {
}

void apply_config(std::unordered_map<std::string, std::string> &&vars) {
#ifndef __ANDROID__
// TODO: Android can possibly support this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, I wrote a comment on this for the last review but it didn't appear for some reason.

I think we discussed this on Discord some time back, but can you explain here why it's not supported right now? In my mind this should work, but I might be missing something.

In my mind, the default "Desktop" application could be renamed to "Screen" or something along those lines. Then the user could add the commands for other applications that would launch an app. Maybe I am missing something?

For reference, these are the current three apps.json files:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I haven't decided on the form of Sunshine Android yet - whether it will be an APK, a binary launched via adb, or both options

The difference is that if it's an APK, the app will need to request screen recording permissions from users, with the readable directory being /data/data/com.xxx/files

If it's a binary launched through adb, no permissions would be needed, with the readable directory being /data/local/tmp

These two approaches have different readable directories, so I'd like to implement this when I have more time available

@FrogTheFrog
Copy link
Contributor

If possible @FrogTheFrog, could you check the updated logging section?

LGTM

@mengyanshou
Copy link
Contributor Author

Seems pretty good to me. In addition to my one question below, I have one more. If possible @FrogTheFrog, could you check the updated logging section?

What would it take to compile this in our CI (understanding no apk would be provided yet)? Could you provide instructions either here or in https://github.com/LizardByte/Sunshine/blob/master/docs/building.md

Regarding CI, as mentioned above, if it's a binary, we would need to compile the entire Sunshine using NDK, which is more complex and requires additional code. If it's an APK, we would need to introduce gradle for compilation. However, we're still in the very early stages - I've only merged some Android-compatible code into Sunshine, but currently we cannot compile either an APK or binary with these changes. Therefore, CI work will need to wait until the entire Android compatibility code is completed. The initial idea is to make it compatible with Android while not affecting any of Sunshine's original code

Copy link

codecov bot commented Jul 14, 2025

Bundle Report

Bundle size has no change ✅

Copy link

codecov bot commented Jul 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 11.31%. Comparing base (feac806) to head (938aac1).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #3741     +/-   ##
=========================================
  Coverage   11.31%   11.31%             
=========================================
  Files          92       92             
  Lines       17571    17571             
  Branches     8239     8239             
=========================================
  Hits         1989     1989             
+ Misses      14901    13063   -1838     
- Partials      681     2519   +1838     
Flag Coverage Δ
Linux-AppImage 11.02% <ø> (ø)
Windows-AMD64 12.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/config.cpp 0.00% <ø> (ø)
src/logging.cpp 55.03% <ø> (ø)

... and 29 files with indirect coverage changes

@ReenigneArcher ReenigneArcher merged commit 4478fd2 into LizardByte:master Jul 14, 2025
48 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants