-
Notifications
You must be signed in to change notification settings - Fork 46
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
Feature/android support #101
Conversation
@@ -32,13 +32,16 @@ jobs: | |||
build-editor-debug: | |||
strategy: | |||
matrix: | |||
os: [ubuntu-latest, macos-latest, windows-latest] | |||
name: [ Linux, OSX, Windows ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because on exports I had to rename it to not have confusions between x11 and android. So to keep it coherent, I renamed for all cpp jobs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this should contain Android
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no editor build for android.
@@ -5,13 +5,16 @@ jobs: | |||
build-editor-release: | |||
strategy: | |||
matrix: | |||
os: [ ubuntu-latest, macos-latest, windows-latest ] | |||
name: [ Linux, OSX, Windows ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here - I don't think this is necessary.
docs/src/doc/user-guide/exporting.md
Outdated
godot { | ||
isAndroidExportEnabled.set(true) | ||
dxToolPath.set("${System.getenv("HOME")}/Android/Sdk/build-tools/30.0.3/dx") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use standard android env variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean ANDROID_HOME
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm according to https://developer.android.com/studio/command-line/variables ANDROID_HOME
is deprecated and replaced by ANDROID_SDK_ROOT
. Will update the places in the docs and the commented line in build.gradle.kts
of tests
src/gd_kotlin.cpp
Outdated
@@ -35,7 +40,33 @@ jni::JObject to_java_url(jni::Env& env, const String& bootstrapJar) { | |||
return url; | |||
} | |||
|
|||
jni::JObject create_android_class_loader(jni::Env& env, const String& full_jar_path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just inline this in create_class_loader
? create_android_class_loader
wont be called elsewhere right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_android_class_loader
is also called in GDKotlin::init
, while initializing bootstrap.
src/jni/env.cpp
Outdated
@@ -62,7 +59,7 @@ namespace jni { | |||
if (exception_check()) { | |||
exception_describe(); | |||
exception_clear(); | |||
throw JniError("An exception has occurred!"); | |||
JVM_CRASH_COND_MSG(true, "An exception has occurred!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A jvm exception shouldn't cause the engine to crash. If we can't use exceptions here - I suggest that we start implementing what C# did. Make the behaviour when an exception happens in jvm configurable. So either crash completely, or just log the message (maybe using ERR_FAIL_COND_MSG?). When in tool mode, we shouldn't crash to stop misbehaving plugins from crashing the engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. But as we need to change this in more places in general, I suggest doing this in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not agree when I read code.
I'm not for checking exception every time we make a jvm call (which is the case for now).
I agree in debug we should make this check, tool should not crash. But in release mode I think we should think a bit more. Even if it is only a bool check, it is a bool check for every jvm method call.
Thing is our module is here to enable user to bring game logic. We should take the less cpu time possible, so that user have much for its game logic.
I think we should run flamegraph to see check_exception impact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I made it crash only in debug when not in TOOL, otherwise it prints error. But we'll have to think a bit more to exception handling.
src/kotlin_editor_export_plugin.cpp
Outdated
) != OK) { | ||
LOG_ERROR("Cannot copy jre folder to export folder, please make sure you created a jre in project " | ||
"root folder using jlink.") | ||
if (!p_path.ends_with(".apk")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not hold up anymore with 3.2.4!
As 3.2.4 will add bundle support. Not sure if just checking for aar
as well is enough but most probably it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godotengine/godot#42185
and godotengine/godot-proposals#1111 respecively
@@ -35,8 +40,25 @@ jni::JObject to_java_url(jni::Env& env, const String& bootstrapJar) { | |||
return url; | |||
} | |||
|
|||
jni::JObject create_class_loader(jni::Env& env, const String& bootstrapJar) { | |||
jni::JObject url = to_java_url(env, bootstrapJar); | |||
jni::JObject create_class_loader(jni::Env& env, const String& full_jar_path, const jni::JObject& p_parent_loader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parent_class_loader is not being used in the non android path. As I've mentioned before URLClassLoader's constructor accepts a class loader as the second parameter :)
src/kotlin_editor_export_plugin.cpp
Outdated
String bootstrap_jar{"res://build/libs/godot-bootstrap.jar"}; | ||
String main_jar; | ||
String bootstrap_jar; | ||
if (p_path.ends_with(".apk")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here aar is missing as well
… is dummy doing nothing
…tArgs and get ClassLoader from android platform
…n android, platform ready
bfe8da4
to
d34984c
Compare
This adds android platform support.
This enable to export game. Only thing to do is the same as classic godot build.
Kotlin project Dex jars will be created if user enable android build in gradle project.
This modifies CI to add Android build for debug and release exports. Also build steps names have changed, explaining the expected but not run CI jobs.