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

Specify the path to the Java SDK used for the Android gradle build #86383

Merged

Conversation

m4gr3d
Copy link
Contributor

@m4gr3d m4gr3d commented Dec 21, 2023

Introduce an editor setting to allow users the ability to specify the path to the Java SDK used for the Android gradle build.
At build time, a gradle task validates the java version and prints out an error if it doesn't match the target version

Screenshot 2023-12-21 at 3 25 47 AM

@m4gr3d m4gr3d added bug platform:android topic:porting topic:export cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Dec 21, 2023
@m4gr3d m4gr3d added this to the 4.3 milestone Dec 21, 2023
@m4gr3d m4gr3d force-pushed the editor_export_specify_java_sdk_path_main branch from 9cd00a6 to 1412849 Compare December 21, 2023 11:27
@m4gr3d m4gr3d marked this pull request as ready for review December 21, 2023 11:31
@m4gr3d m4gr3d requested a review from a team as a code owner December 21, 2023 11:31
@m4gr3d m4gr3d force-pushed the editor_export_specify_java_sdk_path_main branch from 1412849 to 6825eaf Compare December 22, 2023 00:53
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Looks great!

platform/android/export/export_plugin.cpp Outdated Show resolved Hide resolved
platform/android/export/export_plugin.cpp Outdated Show resolved Hide resolved
platform/android/export/export_plugin.cpp Outdated Show resolved Hide resolved
Introduce an editor setting to allow users the ability to specify the path to the Java SDK used for the Android gradle build.
@m4gr3d m4gr3d force-pushed the editor_export_specify_java_sdk_path_main branch from 6825eaf to 85e98ef Compare January 18, 2024 17:19
@YuriSizov YuriSizov merged commit 6fa577c into godotengine:master Jan 18, 2024
16 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

@m4gr3d m4gr3d deleted the editor_export_specify_java_sdk_path_main branch January 18, 2024 18:32
@goatchurchprime
Copy link

I think there's still an issue here, because the values stored in the editor settings will continue to over-ride these JAVA_HOME and ANDROID_HOME environment values if they are not reset-to-default. This is only going to help people when they make a fresh install with no preset editor settings.

The most user-friendly option might be to make these boxes read-only in the UI with a tooltip that says they've been defined by the environment variables.

image

Attached is my nix-flake that I use to make godot with some edits to the source code that force-set all these values with the following substitutions:
flake.zip

                substituteInPlace platform/android/export/export_plugin.cpp \
                    --replace 'String sdk_path = EDITOR_GET("export/android/android_sdk_path")' 'String sdk_path = std::getenv("tunnelvr_ANDROID_SDK")'

                substituteInPlace platform/android/export/export_plugin.cpp \
                    --replace 'EDITOR_GET("export/android/debug_keystore")' 'std::getenv("tunnelvr_DEBUG_KEY")'

                substituteInPlace platform/android/export/export_plugin.cpp \
                    --replace 'EDITOR_GET("export/android/java_sdk_path")' 'std::getenv("tunnelvr_JAVA_SDK_PATH")'

                substituteInPlace editor/editor_paths.cpp \
                    --replace 'return get_data_dir().path_join(export_templates_folder)' 'return std::getenv("tunnelvr_EXPORT_TEMPLATES")'
                    
                    <snip>
                    
                        wrapProgram $out/bin/godot4 \
                            --set ANDROID_HOME "${androidenv}/share/android-sdk"\
                            --set JAVA_HOME "${pkgs.jdk17}/lib/openjdk"\
                            --set tunnelvr_ANDROID_SDK "${androidenv}/share/android-sdk"\
                            --set tunnelvr_JAVA_SDK_PATH "${pkgs.jdk17}/lib/openjdk"\
                            --set tunnelvr_EXPORT_TEMPLATES "${export-templates}/templates" \
                            --set tunnelvr_DEBUG_KEY "${debugKey}" \
                            --set GODOT_BLENDER3_PATH "${pkgs.blender}/bin/" \
                            --set GRADLE_OPTS "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidenv}/share/android-sdk/build-tools/34.0.0/aapt2"

@m4gr3d
Copy link
Contributor Author

m4gr3d commented Feb 11, 2024

I'm not sure I understand the issue.. Those values are meant to override the env variables so that users with multiple Java and/or Android sdks can specify which one the Godot editor should use.

Making them read only defeats that purpose.

@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants