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

[WIP] Editor Android Port #36776

Closed
wants to merge 1 commit into from

Conversation

thebestnom
Copy link
Contributor

@thebestnom thebestnom commented Mar 3, 2020

with the headstart of @fahrstuhl and my stubbornness android port is starting to look like it getting somewhere

Issue discussing this feature #267
Proposal for this feature: godotengine/godot-proposals#3931

currently in wip because

  • Messy code (and hacky code), would like to get comments on it
  • The editor expect double click, which double tap is not (and I"m pretty sure double tap is not in the api)
  • Can't work on master because it's broken for android (or at least to tools build on android, didn't test without tools true) (opend on 3.2 so we can see the actual changes)
  • gradle way to detect normal build vs android studio build so normal build will add no sign to gradle build task and will not build with tools
  • And more real life testing

Build instruction #36776 (comment)

Android Editor apk if you want to test it for yourself (arm64v8)

EDIT: replaced apk with release_debug version, with directory bug fixed
EDIT2: recompiled over newer master commit (5d880bf)
EDIT3: uploaded a new version and now link set to build folder where I will upload newer versions instead of editing the link everytime

@m4gr3d
Copy link
Contributor

m4gr3d commented Mar 4, 2020

@thebestnom Are the changes in this PR able to compile and build a working version of the Godot editor on Android devices?

@thebestnom
Copy link
Contributor Author

@m4gr3d yes it does, im debugging it from android studio on my oneplus 7t (the build.gradle was changed somewhat to support android studio build)

@aaronfranke aaronfranke added this to the 4.0 milestone Mar 4, 2020
@kuruk-mm
Copy link
Contributor

kuruk-mm commented Mar 4, 2020

I think the only reason to make this is for get users attention like "Godot: You can make a game even in your phone" and photo of a guy with his phone making his own game when he's going to work.

It's a striking feature.

@Zireael07
Copy link
Contributor

I can't see it working on a phone, tbh, due to available screen space limitations, but why not on tablets?

@thebestnom
Copy link
Contributor Author

thebestnom commented Mar 4, 2020

I personally use my phone and I know a lot of people use their android tablets as laptop, I have a foldable keyboard always on me...

And for now the editor works with almost no changes to the code (which is very impressive)

Making the last few fixes should not take too much time, and by the issue (which I should've linked) you can see I'm not the only one that thinks that way

Edit: linked the original issue in the first comment

@thebestnom
Copy link
Contributor Author

thebestnom commented Mar 4, 2020

Also the current code state of the port is on the hacky side, it's kind of a POC in some of it, but it shouldn't take too long to make it properly from here (Im talking mostly on the project manager to editor transition)

@m4gr3d
Copy link
Contributor

m4gr3d commented Mar 4, 2020

@nikhilCad @kuruk-mm given that Android runs on a lot of devices and form factors, this would allow Godot to automatically support them.
Some noteworthy examples would be Android tablets (as mentioned), Chromebooks (useful in education), Android VR devices like the Oculus Quest.

Also this shows that Godot may also run on iOS with the appropriate modifications, which thanks to Apple pushing the iPad would be a large and interesting platform to support.

@thebestnom
Copy link
Contributor Author

thebestnom commented Mar 4, 2020

Ios would be hard because it have no way of touching real files, on android I just had to use the normal unixfFieAccesor for res in editor mode

@fahrstuhl
Copy link

My original motivation was doing gamedev with Godot for teenagers. Not everybody has access to a PC, but nearly everybody has access to a tablet or smartphone. And being able to create a game and then show it off to your friends on the same device is pretty cool. Also, you can attach keyboards, mice and screens to phones.

I don't think you'll be able to do full blown gamedev in the subway but you can definitely work on some last minute changes or try out simple concepts.

@thebestnom
Copy link
Contributor Author

As someone who use python and jupyter notebook on termux on my phone I can say I cab use it for full blown dev

That said, android while support mouse it referring as touch, so it will need to be implemented kinda differently (kinda)

@thebestnom
Copy link
Contributor Author

thebestnom commented Mar 4, 2020

And I'm pretty sure most of us understand why android port should be a thing, so I think we can stop discussing about if we should and start discussing on how to do it the right way? 😄

@thebestnom
Copy link
Contributor Author

thebestnom commented Mar 4, 2020

Current my two main problem that I want to implement first are

  1. Run transition, currently project selector to editor works by changing scene (thanks to @fahrstuhl), so the question is, I can use it with #ifdef but it will not work for running the game (because it will be hard to go back to the editor that way, also it makes debugging for now not possible)

I heard you are trying to change to NativeActivity, will it change anything about that?

  1. Choosing anything in the editor and project selector is done by double click, I think about how I can do it generic so we shouldn't implement it twice for everything that the user will select (not sure double tap is the right event), same for right click

And one small thing, android doesn't support opening file explorer from app so any button that does open in file explorer crashes the app, so I think how to diable those button without too much code (like alerting in the godotio.java file instead of trying to open it)

@m4gr3d
Copy link
Contributor

m4gr3d commented Mar 4, 2020

Current my two main problem that I want to implement first are

  1. Run transition, currently project selector to editor works by changing scene (thanks to @fahrstuhl), so the question is, I can use it with #ifdef but it will not work for running the game (because it will be hard to go back to the editor that way, also it makes debugging for now not possible)

I heard you are trying to change to NativeActivity, will it change anything about that?

@thebestnom It's unlikely we'll go down that path given there are several (present and upcoming) Godot features that are made vastly simpler by using the regular Android activity.
One of the reasons behind switching to the NativeActivity was because all of the Android vulkan samples so far only use the NativeActivity. But I've provided #36603 to show that vulkan integration can be done with the regular Android activity as well.

  1. Choosing anything in the editor and project selector is done by double click, I think about how I can do it generic so we shouldn't implement it twice for everything that the user will select (not sure double tap is the right event), same for right click

Android support mice so the logic will have to be able to distinguish between mouse input, in which case double click can be used, and touch input for which single click should be used to select and open items in the editor.
Same thing for right click. With a mouse connected nothing changes, and with touch input, the logic may have to use long click to simulate right click.

@thebestnom @akien-mga Would InputMap be useful here to abstract the action from the actual input event?

And one small thing, android doesn't support opening file explorer from app so any button that does open in file explorer crashes the app, so I think how to diable those button without too much code (like alerting in the godotio.java file instead of trying to open it)

That doesn't sound right. Can you provide the stacktrace for the crash. You should in theory be able to open any Android apps from another Android app.

@thebestnom
Copy link
Contributor Author

While android support mouse, by my testing and docs it counts as touch with special properties (I would like to be wrong here) InputMap and implementing (in a different pr) mouse inputs for android, would be interesting though

For the crash I would sent you later today, it mostly write that the app tries to get out of it's restrictions

@thebestnom
Copy link
Contributor Author

That doesn't sound right. Can you provide the stacktrace for the crash. You should in theory be able to open any Android apps from another Android app.

error:

android.os.FileUriExposedException: file:///storage/emulated/0/Download/New Game Project exposed beyond app through Intent.getData()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:2083)
at android.net.Uri.checkFileUriExposed(Uri.java:2388)
at android.content.Intent.prepareToLeaveProcess(Intent.java:10791)
at android.content.Intent.prepareToLeaveProcess(Intent.java:10744)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1703)
at android.app.Activity.startActivityForResult(Activity.java:5192)
at android.app.Activity.startActivityForResult(Activity.java:5150)
at android.app.Activity.startActivity(Activity.java:5521)
at android.app.Activity.startActivity(Activity.java:5489)
at org.godotengine.godot.GodotIO.openURI(GodotIO.java:467)
at org.godotengine.godot.GodotLib.touch(Native Method)
at org.godotengine.godot.Godot$8.run(Godot.java:965)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1502)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)

what I think we can do is set type to resource/directory maybe that will help, but I"m not sure

@thebestnom
Copy link
Contributor Author

Shouldn't this be optional? When you are building a normal release version you don't want this in the manifest?

Of course, read the main comment,
Need a way to detect in the android manifest and gradle in general when you build for tools and when you do normal build (and distinguish between the editor apk to the generic one)

@BastiaanOlij
Copy link
Contributor

Cool! I wish i had an android tablet to test this on..
Not much constructive to add at this point but if this works this is really neat!

@thebestnom
Copy link
Contributor Author

@BastiaanOlij Cool! I wish i had an android tablet to test this on..

I use and develop it for my phone... So with a mouse and keyboard it's surprisingly pretty comfortable (even though currently most mouse event doesn't work on android 😅)

@The-Sapphire-Starship
Copy link

The-Sapphire-Starship commented Dec 21, 2021

I'm interested in a Android port of Godot.
What is the current status of the development of this?
I would like to help test this as well. I have 2 tablet that I can help test this on, an 8in Samsung Galaxy tab A, and a 10.36 vastking kingpad m10. What do you need help testing and how do I get the apk for testing?

@thebestnom
Copy link
Contributor Author

I'm interested in a Android port of Godot.
What is the current status of the development of this?
I would like to help test this as well. I have 2 tablet that I can help test this on, an 8in Samsung Galaxy tab A, and a vastking kingpad m10. What do you need help testing and how do I get the apk for testing?

As I said last time 😅
It's mostly done except process communication which will happen in a different pr, need to rebase and organize some things and it's ready to review, but my time is really short in the last 6 month and didn't had the time to do that

@The-Sapphire-Starship
Copy link

The-Sapphire-Starship commented Dec 21, 2021

Great! Few questions,
What version is it made for right now?
Where what is the best way to keep updated on progress and when this is released?
Will it be kept up to date with new versions of Godot as it is released?
(sorry for all the questions, I'm just really excited to try this out)

@thebestnom
Copy link
Contributor Author

Great! Few questions,
What version is it made for right now?
Where can I get the apk to test it?
Where what is the best way to keep updated on progress and when this is released?
Will it be kept up to date with new versions of Godot as it is released?
(sorry for all the questions, I'm just really excited to try this out)

Np
It's for 4.0 (one of them 😅) and download link is in the start of the pr 😄
This pr is the only place to get update and from the second the pr is merged it should be upstream we the same way that the other editors version are upstreamed (at least that the current idea) ☺️

@The-Sapphire-Starship
Copy link

The-Sapphire-Starship commented Dec 21, 2021

Thanks, I realized the download link was in the pr right after I posted those questions, from what I see looking at some of the previous posts that it might be backported to 3.x, is that still in the plans?
I've seen that you have said that you have been busy, do you have any general idea of when this might be officially done and available(no pressure, I'm just curious)?
I tried the apk on my vastking kingpad m10 and it does not open, haven't tested it on my Samsung yet

@thebestnom
Copy link
Contributor Author

Well, 3.x port shouldn't be too hard as this started as 3.x editor, but it will take some changes 😄
In about 2 weeks I will finally leave my job and have a month for myself and os ☺️

@The-Sapphire-Starship
Copy link

Okay, thanks for answering my questions, can't wait to be able to try using Godot on my tablet!

@captain0xff
Copy link

Do you plan release a armv7l build for the 32 bit devices?

@thebestnom thebestnom force-pushed the android_editor branch 2 times, most recently from 42d5ba0 to 82e315d Compare January 11, 2022 01:08
fix execute


use shouldNotStrip for deciding to strip symbol


fix intent


fix running with create_process and merge redundent godotGame and godotEditor
@thebestnom
Copy link
Contributor Author

I need to start compile it with all build type😅
but at least a new version is build!
Tommarow Ill tidy the code up and I think it can already get code review @godotengine/android 😄

platform/android/java/gradle.properties Show resolved Hide resolved
platform/android/java/lib/build.gradle Show resolved Hide resolved
@@ -17,3 +17,5 @@ target_include_directories(${PROJECT_NAME}
SYSTEM PUBLIC
${GODOT_ROOT_DIR}
${GODOT_ROOT_DIR}/modules/gdnative/include)

add_definitions(-DUNIX_ENABLED -DVULKAN_ENABLED -DTOOLS_ENABLED)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allowing Android Studio to correctly show #define

Copy link
Contributor

Choose a reason for hiding this comment

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

Good find. May be worth adding those separately in a small PR so we can all benefit!

platform/android/os_android.cpp Show resolved Hide resolved
platform/android/os_android.cpp Show resolved Hide resolved
@likeich
Copy link
Contributor

likeich commented Jan 17, 2022

I'm having an issue on my Samsung S21. When I run the game I cannot return to the editor main screen. When I press the back button the entire app closes.

Screen_Recording_20220117-105934_World.Launcher.mp4

@thebestnom
Copy link
Contributor Author

I'm having an issue on my Samsung S21. When I run the game I cannot return to the editor main screen. When I press the back button the entire app closes.

Screen_Recording_20220117-105934_World.Launcher.mp4

Yep a known bug 😅
The app actually quit itself because it can't communicate with the correct process

@LinuxUserGD
Copy link
Contributor

I get a black screen with latest editor apk download and apk built from source (Samsung Galaxy S6, zerofltexx, ROM: Lineage OS 17.1, Android 10). It worked with previous apks before but showing glitched color rendering on vulkan.

I tried it again with prebuilt "android_editor_release_debug_2022_01_11.apk" and still get a black screen. Maybe it's an issue with the new mobile vulkan backend and not this pr?

editor/editor_node.cpp Show resolved Hide resolved
platform/android/java/app/build.gradle Show resolved Hide resolved
platform/android/java/app/build.gradle Show resolved Hide resolved
platform/android/java/app/build.gradle Show resolved Hide resolved
@@ -17,3 +17,5 @@ target_include_directories(${PROJECT_NAME}
SYSTEM PUBLIC
${GODOT_ROOT_DIR}
${GODOT_ROOT_DIR}/modules/gdnative/include)

add_definitions(-DUNIX_ENABLED -DVULKAN_ENABLED -DTOOLS_ENABLED)
Copy link
Contributor

Choose a reason for hiding this comment

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

Good find. May be worth adding those separately in a small PR so we can all benefit!

platform/android/os_android.cpp Show resolved Hide resolved
@m4gr3d
Copy link
Contributor

m4gr3d commented Feb 7, 2022

@LinuxUserGD @likeich @filipworksdev @The-Sapphire-Starship @CAPTAIN1947 There's a 3.x version of the Godot Editor Android port in #57747.
Feel free to give it a try and report your feedback!

@captain0xff
Copy link

captain0xff commented Feb 7, 2022

So I tested it on my low end 10.1 inch 32 bit tablet. And as I hadn't expected, its working quite fine. The controls are ok with an external mouse and keyboard. There are a few issues here and there but overall its working. I tried some of the examples and they are also working good without any massive lag.
Now coming to the ui part...
Its usable but not anyway ready for real purposes without an external mouse and keyboard. I know its still a WIP and so here are my few suggestions:-

  • Add a input box above the keyboard so that we can see what we are entering if the software keyboard blocks it.
  • Currently the keyboard pops up now and then without any reason so I think it will be better to control it using the volume buttons. Like maybe volume down for hiding it and volume up for calling it. Or adding a pop up for controlling the virtual keyboard.
  • Currently the navigation bar is not hidden. As the main problem with android phones is small screen size, I think it will be better to have the app fullscreened by default. The toggle fullscreen option is not working.
  • Add pan to zoom support.
  • And yeah at some points the scrolling is terrible.
    Anyways, this project is really fantastic. And its like a dream come true to see the engine running in android.
    I will report again if I find something. And yes feel free to ping me again if needed. :]

@m4gr3d
Copy link
Contributor

m4gr3d commented Feb 7, 2022

@CAPTAIN1947 Thanks for the feedback!!

I've created godotengine/godot-proposals#3931 in order to centralize the discussion / feedback / suggestions regarding this work.
Do you mind posting your feedback on that proposal instead? Thanks!

@m4gr3d m4gr3d mentioned this pull request Feb 15, 2022
@akien-mga
Copy link
Member

Superseded by #58160.

@akien-mga akien-mga closed this Mar 28, 2022
@thebestnom thebestnom deleted the android_editor branch July 5, 2022 17:48
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.