Adventure Game Studio | Forums | SMF 2.1.x Dev

AGS Development => Editor Development => Topic started by: eri0o on 08 Feb 2022, 21:44

Title: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 08 Feb 2022, 21:44
🚨🚨 Experimental Android Build in the Editor 🚨🚨

AGS-3.6.0.17-AndroidBuild_v9.exe  (https://drive.google.com/file/d/1XszddarCJBvJhNm3rZOAAUvBttR-zUzB/view?usp=sharing)
AGS-3.6.0.17-AndroidBuild_v9.zip  (https://drive.google.com/file/d/1xxQgewUQh_si3xETRRAK7RLsKVHzGR6U/view?usp=sharing)


⚠️⚠️ Work in Progress, but just bug fixing now ⚠️⚠️

(https://i.imgur.com/xKPOvNc.gif)
running on your computer may have visual differences

Please test and report. Here's the step by step:


Icons!

At your project root, create a directory named icons with a directory named android inside. Then you need to add the following files ( template here (https://drive.google.com/file/d/1pj_tspvV9VD5QT5zBi9yK1H7oaoWksrt/view?usp=sharing)):


If you want to support round icons, additionally create ic_launcher_round.png files in the same directories. If you need help creating those files, try this online AndroidAssetStudio (https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html).
FAQ





























There is still room for improvement, but this should do the general things...

Also when possible please try these experimental versions of editors that appears in this board, the feedback given can help make ags better. After the feature is already in, some things get a lot harder to change.

[spoiler]
Additionally, I recently started thinking about build matrixes in AGS, if someone has any design idea for this. It looks something like this (this is a different editor than the above):

(https://i.imgur.com/kfZEbtG.png)[/spoiler]
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 09 Feb 2022, 07:10
Amazing. Finally Done!. Nice Job!

I can successfully get apk after 2 hours of upload and build and...

@eri0o
I tested apk on my cellphone with Android 5.1. The result was great although fps was a little low. I will test with increased speed of the game.
And my questions:
1)  How can adjust Landscape or Portrait? I only have portrait
2) Is it possible integrate with unicode editor (Latest version)? I want test it for see fonts
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 09 Feb 2022, 07:26
I haven't yet integrated the Editor to write the proper android config yet, I was interested if people would be able to install Android Studio and it, and getting this working on the computer.

As soon as I integrate the config it should be just a menu entry for rotation.

The apk is made for local testing, but I believe Cafe Bazaar uses the aab + non-embedded asset (same as Google Play), this would be the upload format.

About 2, I could make that version, yes, but I can advance that the Unicode version doesn't support font ligatures yet. Font ligatures requires the Harfbuzz library and we haven't gone there yet. If no font ligatures is fine for now I can create that build, but probably only Friday. Please test the Unicode version separately though, we are probably going to be integrating both later but knowing what works and what doesn't helps polishing the features.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 09 Feb 2022, 07:36
Quote from: eri0o on 09 Feb 2022, 07:26
About 2, I could make that version, yes, but I can advance that the Unicode version doesn't support font ligatures yet. Font ligatures requires the Harfbuzz library and we haven't gone there yet.

We were discussing this on Discord just recently, and turns out Mehrdad has found a way to make it work, using some software called "ParsiNegar" which generates Persian text, which is then copied into the AGS Editor. I'm not exactly sure how it manages to do this, but visually it seems working.

Quote from: eri0o on 09 Feb 2022, 07:26
If no font ligatures is fine for now I can create that build, but probably only Friday. Please test the Unicode version separately though, we are probably going to be integrating both later but knowing what works and what doesn't helps polishing the features.

If you're too busy, maybe I could make a Draft PR for a test with these merged? Assuming it's enough to use your existing android branch. I'd prefer to rely on build server instead of making these by hand.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 09 Feb 2022, 07:53
No problem CW, go ahead!

I think after we are done with this version, we really should look into moving on from our old FreeType to a newer FreeType, so integrating Harfbuzz is easier.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Laura Hunt on 09 Feb 2022, 08:16
I'll try to test this today and report my findings. I remember however that back when I tried out the Android wrapper for AGS 3.5.0, right clicks didn't work and I wasn't able to bring up the phone keyboard either for a section of the game in which you have to type some numbers, but I assume these issues have been dealt with in the meantime?
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 09 Feb 2022, 08:37
No, but in detail:

1. I would much rather support touch up, touch move, and touch down events, and have multitouch in some GUI elements (buttons). I have a writeup here: https://ericonotes.blogspot.com/2020/11/a-quick-look-at-touch-handling-apis-in.html

I think adapting mouse to touch is bad, the developer should handle touch input differently.

2. Keyboard is not there, the problem is this was done through a menu, but SDL2 is done in a way that it grabs the surface and draw and it's over painting any control I throw on top. If we had something like dear imgui I could make a nice UI in c++ itself but as is I haven't yet figured any way to do in Java. I would rather have proper 1 and let people implement this in-game.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 09 Feb 2022, 08:39
Quote
We were discussing this on Discord just recently, and turns out Mehrdad has found a way to make it work, using some software called "ParsiNegar" which generates Persian text, which is then copied into the AGS Editor. I'm not exactly sure how it manages to do this, but visually it seems working.


Yes, I made a PDF guide too
https://www.dropbox.com/s/j8hwfpfzqzcprpl/Persian%20and%20Arabic%20fonts%20in%20AGS.pdf?dl=0
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 09 Feb 2022, 09:00
Quote from: eri0o on 09 Feb 2022, 08:37
I think adapting mouse to touch is bad, the developer should handle touch input differently.
<...>
I would rather have proper 1 and let people implement this in-game.

The problem is that we were using Android port not only to make games, but also to run existing games whose authors were not preparing for Android (this is what "universal" game launcher was meant for, as 99% of AGS games do not have proper mobile ports). This is why we need some basic controls/keyboard as a default solution for such cases.


Quote from: eri0o on 09 Feb 2022, 08:37
2. Keyboard is not there, the problem is this was done through a menu, but SDL2 is done in a way that it grabs the surface and draw and it's over painting any control I throw on top.

Was it done by drawing a keyboard control right on top of the game's surface in the old port? I wish i knew more about this.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 09 Feb 2022, 09:13
Suggestion: Please add "release mouse" instead "click" for control character. It's useful for mobile ports as a user touch screen for finding hotspots no walking.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 09 Feb 2022, 09:41
Honestly the ags player as is I would rather let ScummVm take the throne there.

But still on the keyboard, what we need is support System.ShowKeyboard instead. Also a reminder, we can't use the back button anymore on Android, since it's now handled by gesture - back button is gone in latest Android versions.

We should first and foremost support developers doing their mobile ports, multitouch would allow making a GUI controls for on screen joysticks. Supporting players who have put their games there come latest in my opinion. If we switched this mode of thinking the agsplayer could be repurposed more as a companion to the Editor, similar to the original Phonegap app, where it let me type the local IP address of the PC the Editor is running, and then we can have things like debug, log, ...

But going back a bit, we need to get rid of the android.cfg and use acsetup.cfg instead, this is the first priority. And add a rotation config there, in acsetup.cfg.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 09 Feb 2022, 11:48
The Editor combining Android + Unicode may be downloaded from here:
https://cirrus-ci.com/task/5505374429118464
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Joseph DiPerla on 10 Feb 2022, 04:35
I tried this out. Great Work! Works like a charm. Just needs some configuration settings like loading in landscape mode, etc.. and this will be another notch in AGS' belt.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 10 Feb 2022, 09:02
I have been thinking about rotation, perhaps it could use an auto config for now. If the game has height bigger than width it sets portrait, and if not, landscape.

I would like to redo how the build process of AGS works, but I am not sure I can do it fast enough and bug free enough to be something that gets in 3.6.0, but ideally I would like to be possible so you can selectively exclude rooms or set macros and things and build different versions of game data, possibly paired with different versions of acsetup.cfg and then can choose what gets build to which system and things like that. But there's already a plan to get after 3.6.0 is done a version of the editor that uses command line tools to build AGS games so I think I would prefer to have that happen at that time. So currently there is no reasonable panel to place things like an adb interface or a gradle interface. :/
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 10 Feb 2022, 09:57
Quote from: eri0o on 10 Feb 2022, 09:02
I would like to redo how the build process of AGS works, but I am not sure I can do it fast enough and bug free enough to be something that gets in 3.6.0, but ideally I would like to be possible so you can selectively exclude rooms or set macros and things and build different versions of game data, possibly paired with different versions of acsetup.cfg and then can choose what gets build to which system and things like that. But there's already a plan to get after 3.6.0 is done a version of the editor that uses command line tools to build AGS games so I think I would prefer to have that happen at that time. So currently there is no reasonable panel to place things like an adb interface or a gradle interface. :/

I honestly think it's best to switch focus to ags4 soon after 3.6.0, where you can overhaul whatever you like, cutting old features if necessary. ags4 has been in development "limbo" for a long while now, and becomes stale. There's a new script compiler with lots of useful features, an open room format almost ready, and someone may eventually do open sprite format as well. I fear that pretty soon someone asks: why cannot we have these features if they are ready? Then someone will get an idea to start moving them to 3.* branch, and development will go on a new cycle of getting stuck in a 3.* again. This happened before, several times, in the last 5 or so years.

The 3.6.0 was not supposed to be as big as it became, the sole purpose of it initially was to have a SDL2-based engine that has full backward compatibility, as a backup. I'm afraid that pushing changes there further will eventually come in conflict with this concept. When I started 3.6.0 there were two major goals: SDL2 and command-line build tools. SDL2 is practically done, and tool development was unfortunately frozen at some point. But compatible tools may be added to that branch later when time permits, or even backported from ags4 if they are first done there.

[REDACTED] removed unnecessary ramblings
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 10 Feb 2022, 10:28
I agree 100% with moving to ags4 right after. Just to clarify, we can really do the tools there and backport if needed, I think it's the better way too.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 10 Feb 2022, 11:05
Quote from: eri0o on 10 Feb 2022, 10:28
I agree 100% with moving to ags4 right after. Just to clarify, we can really do the tools there and backport if needed, I think it's the better way too.

Sorry, did not mean to discourage you, or anything! I just suddenly got agitated, wondering if more things will be put on 3.6, while we already have a big list of planned but undeveloped features there.

The idea of build configurations where you may select files and compile options sounds pretty interesting. I guess right now this may already be doable to some extent by writing package scripts by hand which call agspak and compiler tools? I wish we had some kind of "feature group lists" that describe these ideas for the future, and all related tasks (e.g. "Automated game building"), so that everyone could know where we are going.

But this is offtopic here, so I will shut up.

Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 10 Feb 2022, 11:21
It's already doable with agspak and scripts, you even wrote one .bat script at some point - I have it in my computer, but I can't find it on GitHub.

---

Back on Android, it appears that while the first level of a menu is drawn behind the SDL surface view no matter what I do, it seems the second level is always drawn on top. The caveat is the second level of the apparently blocks the application. So it seems the doable way is when the menu opens, open programatically an option, and then have all menu options under this one, and also delay all actions done from the selections by using timer with the action on the callback. I need to test this to verify that this really works alright on different devices...

Edit: Android is too mystical and the above didn't work. I found a way that is blowing up the game screen, drawing the menu, and picking up the game screen back after the menu is closed. It looks terrible but it worked.

Edit: done!
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 12 Feb 2022, 16:24
@Laura Hunt, I added the keyboard toggle and extra keys on the above (updated the download on the link too), you should be able to reach it by using either the back button or the back gesture (depending of android version/config) when in game.

I hope I can get rotation working later this weekend.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Laura Hunt on 12 Feb 2022, 18:32
Unfortunately, this did not work for me. First I got the following error:

(https://i.imgur.com/ZF1FeSa.png)

And then on subsequent tries, this one:

(https://i.imgur.com/qSmH4oJ.png)

This is a short extract (it was much longer) of the error message that can't be seen in the screenshot (with my Windows username redacted):

Quotesymbol:   variable key_ctrlx
  location: class id
C:\Users\xxxxx\Documents\AGS Projects\ioawn4t - Android\Compiled\Android\library\runtime\src\main\java\uk\co\adventuregamestudio\runtime\AGSRuntimeActivity.java:238: error: cannot find symbol
        } else if(id == R.id.exitgame) {
                            ^
  symbol:   variable exitgame
  location: class id
C:\Users\xxxxx\Documents\AGS Projects\ioawn4t - Android\Compiled\Android\library\runtime\src\main\java\uk\co\adventuregamestudio\runtime\AGSRuntimeActivity.java:240: error: cannot find symbol
        } else if(id == R.id.toggle_keyboard) {
                            ^
  symbol:   variable toggle_keyboard
  location: class id
C:\Users\xxxxx\Documents\AGS Projects\ioawn4t - Android\Compiled\Android\library\runtime\src\main\java\uk\co\adventuregamestudio\runtime\AGSRuntimeActivity.java:251: error: cannot find symbol
        return R.menu.default_ingame;
                ^
  symbol:   variable menu
  location: class R
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

I'm not sure if this is because I was using a game with script compatibility level set to 3.4.1, but right now I don't have a game compiled with 3.6.0 to test.

Also, an interesting side effect was that in the compiled Windows version, frame-linked sounds were not playing at all. I don't know what this has to do with the changes introduced for the Android build, but I can confirm that when I compiled and ran my game with the "vanilla" AGS 3.6.0.17 Alpha 18 build, those sounds played correctly.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 12 Feb 2022, 20:23
This usually means that JAVA_HOME is set to directory where JDK was not installed. Did you set up Java through a separate installer or are you using the one that is provided along Android Studio? If you are the one with android Studio, can you tell me which version?
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Laura Hunt on 12 Feb 2022, 21:01
I installed everything though Android Studio, the latest version 2021.1.1 Patch 1. The path is correct, C:\Program Files\Android\Android Studio\jre.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 12 Feb 2022, 22:00
Quote from: Laura Hunt on 12 Feb 2022, 18:32
Also, an interesting side effect was that in the compiled Windows version, frame-linked sounds were not playing at all. I don't know what this has to do with the changes introduced for the Android build, but I can confirm that when I compiled and ran my game with the "vanilla" AGS 3.6.0.17 Alpha 18 build, those sounds played correctly.

There's something broken in the master branch after the audio refactor i did few days ago.

From my own tests, ViewFrame sounds sometimes play and sometimes don't, which seem random.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 12 Feb 2022, 22:16
Quote from: Laura Hunt on 12 Feb 2022, 21:01
I installed everything though Android Studio, the latest version 2021.1.1 Patch 1. The path is correct, C:\Program Files\Android\Android Studio\jre.

Thanks, I found the error! I will upload a new version that should take care of this, just need to check if I made any more mistakes on this part. :/

Edit: actually turns out it was 3 errors. I am still checking to see if there's something more I missed.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 13 Feb 2022, 02:07
@Laura Hunt, I think I fixed all the errors (erh, at least the reported ones, if there are more, please tell me!). Thanks for the screen caps and the error messages! They were very helpful! I setup from a new install in my PC here and it appears it's working. I updated the files on the google drive linked in the first post!

Ah, right, about the sound, what CW said. It should be fixed soon.

@Mehrdad, I added the rotation config through Default Setup and updated the main post. It should be working now. About the click, I agree there are necessary enhancements for touch input. I wrote the general gist of what I think here (https://github.com/adventuregamestudio/ags/issues/1538), but I won't be working in this just right now. For now I want to get the build working.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Laura Hunt on 13 Feb 2022, 07:13
With the new build I'm not getting the reported errors anymore, but:

Quote> Task :app:validateSigningRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'C:\Users\xxxxx\Documents\AGS Projects\ioawn4t - Android\Compiled\Android\mygame\app\Γ?¬C:\Users\xxxxx\keystore.jks' not found for signing config 'release'.

I guess this error is on my side, but I generated my key through Android Studio itself so I have no idea what might have gone wrong (Build->Generate APK->Create new->Filled everything out->Selected 'release' as build variant.)
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 13 Feb 2022, 08:10
Quote
@Mehrdad, I added the rotation config through Default Setup and updated the main post. It should be working now. About the click, I agree there are necessary enhancements for touch input. I wrote the general gist of what I think here, but I won't be working in this just right now. For now I want to get the build working.

@eri0o

Great!. I tested "Lanscape" now and works perfect but with a little issue. After run, I have some multi-screen ( Below picture). But it solves itself after some clicks. (like mobile back key )

I have Android 5.1.  With Api 19 or 20 I think so. It's really old cellphone :-D

I tested back click too and works perfect for "F1,F2,..." and "show keyboard" and "exit"

As I said before we need to "release mouse" instead "press down" on mobiles. User wants search hotspots with finger moves on screen. It start to walking with "press down" and mobile users don't want it.

Thanks so much again for your hardworks

(https://www.uplooder.net/img/image/73/1461d10f09da86674a0cea35c5d86fcb/IssueAndroid.png)
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 13 Feb 2022, 08:50
@Laura Hunt, I will investigate, it may be something like special characters on path, spaces on a folder name or something else not related. I will try to reproduce here and see if I can figure it out.

@Mehrdad, the image is weird, I don't know what could be yet. Have you tried changing the renderer, like do you get that same image with both OGL and Software renderer? I have no idea what could be to cause that image yet.

About control scheme I don't fully understand what you mean yet, but again, multi touch or a more natural touch scheme is not something I am going to look into now. This would require touch specific events which would allow the developer to script whatever scheme they feel they want, instead of hardcoding any behavior at all.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Laura Hunt on 13 Feb 2022, 08:56
Quote from: eri0o on 13 Feb 2022, 08:50
@Laura Hunt, I will investigate, it may be something like special characters on path, spaces on a folder name or something else not related. I will try to reproduce here and see if I can figure it out.

There are no special characters or spaces in the path or anything of the sort, so it's likely that I've done something wrong at some point, given that it works for Mehrdad and Joseph. If you can figure it out or provide detailed instructions as to how to create a keystore that would be great, but if not, no worries. At least Mehrdad has confirmed that it works correctly, and I'm sure somebody else will step in to test it too :)
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 13 Feb 2022, 09:18
I meant more there's an hyphen in your game dir, after a space character, I don't know if this may trigger something somewhere to think the directory may be a parameter. (Yes, I should escape characters as needed, but I am still writing the escaping code so for now it's not good :/)

Anyhow, if you set the password for the keystore and the keystore location in the AGS Editor -> Preferences -> Advanced -> the things under Android, when setting the Android Keystore path the Editor do checks to see if it's really there. There's also a very weird thing that Android Studio asks now is that the keystore and the key passwords are the same. I haven't tried using different ones to see what kinda of error message it outputs. I am out of home now, will check when I get back.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Laura Hunt on 13 Feb 2022, 10:11
Quote from: eri0o on 13 Feb 2022, 09:18
I meant more there's an hyphen in your game dir, after a space character, I don't know if this may trigger something somewhere to think the directory may be a parameter. (Yes, I should escape characters as needed, but I am still writing the escaping code so for now it's not good :/)

My game dir was "ioawn4t - Android", so I changed it to "ioawn4tAndroid" and moved it to a path with no spaces or hyphens whatsoever, and I'm still getting the same error.

Quote from: eri0o on 13 Feb 2022, 09:18
Anyhow, if you set the password for the keystore and the keystore location in the AGS Editor -> Preferences -> Advanced -> the things under Android, when setting the Android Keystore path the Editor do checks to see if it's really there. There's also a very weird thing that Android Studio asks now is that the keystore and the key passwords are the same. I haven't tried using different ones to see what kinda of error message it outputs. I am out of home now, will check when I get back.

Both passwords are the same, yes. And the .jks file is definitely there in the path that I entered (no spaces or anything there either).

btw, when I close the editor, the process OpenJDK Platform Binary keeps running hogging a ton of memory, and it keeps some files locked until I kill it from the Task Manager. Not sure if this is useful to know!

Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 13 Feb 2022, 12:50
Quote from: eri0o on 13 Feb 2022, 08:50

@Mehrdad, the image is weird, I don't know what could be yet. Have you tried changing the renderer, like do you get that same image with both OGL and Software renderer? I have no idea what could be to cause that image yet.

About control scheme I don't fully understand what you mean yet, but again, multi touch or a more natural touch scheme is not something I am going to look into now. This would require touch specific events which would allow the developer to script whatever scheme they feel they want, instead of hardcoding any behavior at all.

I forgot adjust it on openGL and it's on D3D. Maybe problem is here.Also, I'll change "Fullscreen scaling style" too. I'll test it and let you know. Please if anyone has my problem let me know too maybe my Android is too old. ( Android 5.1)

For touch: My mean is please add "release mouse" to AGS system. It works on "press mouse" now and it's not suiatble for mobiles
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 13 Feb 2022, 12:52
Quote from: Mehrdad on 13 Feb 2022, 08:10
As I said before we need to "release mouse" instead "press down" on mobiles. User wants search hotspots with finger moves on screen. It start to walking with "press down" and mobile users don't want it.

@Mehrdad, indeed AGS currently does not have a ready event for released mouse, but you can change your script to react to the mouse state change (pressed - released) in the repeatedly_execute.

To do this:
1) have a global variable to remember last mouse button state
2) check in repeatedly_execute for the current mouse button state
3) compare to the last saved state. If button's state changed, do the action.
4) save new state in the variable.

Code (ags) Select

bool was_mouse_down;

function repeatedly_execute()
{
     bool mouse_down = Mouse.IsButtonDown(eMouseLeft);
     if (mouse_down && !was_mouse_down)
     {
         // user just pressed the button
     }
     else if (!mouse_down && was_mouse_down)
     {
         // user just released the button
     }
     was_mouse_down = mouse_down; // remember new state
}


Also I may recommend speaking with Wadjet Eye (Dave and Janet Gilberts) and other people who ported their games to mobile, perhaps they will have some advices.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 13 Feb 2022, 13:12
@Crimson Wizard

Sorry, I didn't right understand. Do must I make global variables? And after that how can I fill your conditions?

I remember to play Gemini Rue on my cellphone and had this problem.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 13 Feb 2022, 13:29
Quote from: Mehrdad on 13 Feb 2022, 13:12
Sorry, I didn't right understand. Do must I make global variables? And after that how can I fill your conditions?

You fill them with actions corresponding to the event. Just like you fill on_mouse_click now.

For a simple example:
Code (ags) Select

     else if (!mouse_down && was_mouse_down)
     {
         // user just released the button
         // call room interaction (walking, using objects, etc)
         Room.ProcessClick(mouse.x, mouse.y);
     }


If there are more problems with this code, I suggest discussing this in the "Technical help" forum, as this is mostly a scripting question.

Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 13 Feb 2022, 16:12
I just added a minor FAQ on the first post (https://www.adventuregamestudio.co.uk/forums/index.php?topic=59772.msg636643437#msg636643437). I surely would like to automate things a bit more but I am afraid Google may change some things just too fast. I haven't yet figured the signing problem (I just blew up my install and started from scratch and it's working, so I could not reproduce it yet), if someone else hit it too, please let me know.

I also haven't yet figured what to do about the icons. This icons.zip (https://drive.google.com/file/d/1pj_tspvV9VD5QT5zBi9yK1H7oaoWksrt/view?usp=sharing) has how they look like. I am thinking of simply asking for a directory in the project called AndroidIcons with the contents of this zip prepared for your game. Not sure on this yet. If anyone has any ideas, please share.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 14 Feb 2022, 15:19
@eri0o
I tested again with openGL and "Fill whole screen" mode. I had same problem again. It improve after a refresh screen like pressing the back button or on/off screen and so on 

Does anyone have this problem?
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 14 Feb 2022, 18:56
Hey Mehrdad. I don't have that issue on my phones so far. I tried a few ideas but could not reproduce. In the back button, the keys entry, one of them is Ctrl+V, if you hit it, it should load a display with some information. Can you capture a screenshot of that when you have that problem? Or does it "clean" the screen as soon as you hit back button?
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 15 Feb 2022, 06:04
 It "clean" the screen as soon as you hit back button or others. So I can't capture the screen   (wtf)
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 15 Feb 2022, 15:15
I'm testing this Android building now. After setting up ANDROID_HOME and JAVA_HOME, I'm getting following error in the command window:

Hide: ShowHide

Quote
FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Dev\ags-games\ags-camdemo\Compiled\Android\mygame\app\build.gradl
e' line: 31

* What went wrong:
A problem occurred evaluating project ':app'.
> path may not be null or empty string. path=''


What is this "path" variable refering to, do I need to also set it?
EDIT: Oh, looking at the code, this is keyStoreProperties not set. I wish there was some kind of error message thrown with more details.

UPDATE 1: I hate Android Studio because it looks strange and I cannot find anything it its menus.
So ended up generating keystore from command line following instructions:
https://stackoverflow.com/questions/3997748/how-can-i-create-a-keystore

UPDATE 2: next problem:

Hide: ShowHide

Quote
* What went wrong:
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.

> Failed to install the following Android SDK packages as some licences have not
been accepted.
     patcher;v4 SDK Patch Applier v4
     emulator Android Emulator
     build-tools;30.0.3 Android SDK Build-Tools 30.0.3
     platform-tools Android SDK Platform-Tools
     platforms;android-29 Android SDK Platform 29
     tools Android SDK Tools
  To build this project, accept the SDK license agreements and install the missi
ng components using the Android Studio SDK Manager.

So, there are missing components, but I have two questions:
- why is emulator required to build the game?
- is the SDK platform version a variable somewhere, or this is hardcoded, and we must use exactly that version?
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 15 Feb 2022, 16:14
🔐 Keystore

I can put a menu for creating the keystore, but I have no idea where to put such menu.

About the error message, I thought I had put a check for that but apparently it didn't got committed somehow. I am going to fail the build earlier if the keystore settings are empty/invalid.

Edit: there's now a Generate Keystore button in preferences to load the keystore generation dialog.




☑️ Requirements

About the requirements, it's:

- SDK is needed for the Android API that is accessible through Java or Native. We will always need it. It matches the compile API target. This one changes at least once per year because of Google Play policies.

- Build Tools are the tools for building. Ideally we always want these to be the latest as possible. They are not dependant of the target you are building or the SDK. The emulator it comes is probably some interface, but it doesn't download any images. We will always need it. We can change this only if there's a bug building newer SDKs.

- NDK may be needed too. We are not directly using it to build C++, but some minification of native code apparently needs it. Theoretically it should be possible to build the runtime library project to a jar and then depend of this jar elsewhere, but I could not figure out a sane way to do this (without needing to push this as a package in Maven). I don't want to pursue eliminating this now and going the jar approach. NDK is similar do build tools in being independent of target version. I also may be wrong here and we don't depend on NDK already.

These versions are all anotated in the Gradle build scripts. The Editor requests and install them.

The current minimal target is set to 29 because of SDL2 version we are using. For Play Store this needs to be 31 minimum. This requires some minor updates in the manifests (https://github.com/libsdl-org/SDL/commit/2f591fb0a0f1dbe1d4a0e6477df89c694e9f60f4) which I plan to do later. See  https://developer.android.com/distribute/play-policies

I know how to ask for installation and it should ask for installation, but if it asks about license approval I could not figure out how to not use Android Studio for accepting the licenses.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 15 Feb 2022, 17:13
Is it possible to post a list of components that I have to check and install in the SDK Manager? Because I tried installing the ones from error message, was not able to find all of them in the list, and even after i installed some of them it kept reporting same missing components again.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 15 Feb 2022, 17:46
On the top post there's a FAQ, in the first entry I mentioned the SDK, it's a bit weird, but I need to have something installed to get the sdkmanager. Once the sdkmanager is in place I can use it to install other things.

It does come with a little yes script that can be used to accept following licenses, perhaps I could use and assume that everyone trying to use agrees with the licenses - just need to check the script works on Windows.

Anyway, AGS Editor above should try to install things after a sdkmanager is installed, if it's not doing that, it's a bug.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 15 Feb 2022, 19:31
Right now I have following installed (checked in the SDK manager):

SDK Platforms:
* Android 11 (api level 30)
* Android 10 (api level 29)

SDK Tools:
* Android SDK build tools: 32.0.0, 30.0.3, 29.0.3
* NDK (side by side): 22.0... , 21.3...
* Android command line tools 6.0
* Android emulator 30.3.5
* Android SDK platform tools 30.0.5


May someone else say what do they have?

May the problem be that I set wrong path to ANDROID_HOME? Do I need to set it to the Android Studio root folder, or to one of the subfolders?
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 15 Feb 2022, 20:06
ANDROID_HOME is set to the SDK path (should be a dir named Sdk, see first post!)

JAVA_HOME should be the path to JDK, which is confusingly a directory that ends in jre (but it's not JRE!), and this one is on the Android Studio directory (again, see first post)

Question: which Android Studio you have?

I can try to come up with some heuristics to try to search and find out both above, so I can automatically fill ANDROID_HOME and JAVA_HOME but I don't know at which point I should run this.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 15 Feb 2022, 20:35
Ok, sorry, I made a mistake. There apparently have been some older version of SDK from couple of years ago, which I thought is current one.
The directory in "...\AppData\Local\Android\Sdk" was practically empty with only 1 file inside.

I fully deleted Android Studio and SDK from my system to be certain, and resintalled again using most recent version, and double checked the new paths. Now the building is running (still waiting for result while I type this).

UPDATE: it completed successfully now, and there's app-mygame-release.apk.
Maybe a silly question, but should not it use game's name? or I missed another instruction?
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 15 Feb 2022, 21:11
You forgot to set the package name of your game in the general settings! If you did and still got that, it's a bug! :)

Edit: adjusted to get clearer error messages on wrong/missing config of ANDROID_HOME, JAVA_HOME and Keystore path. Also I had forgotten to set the app name you see when browsing apps and now it should correctly pick your game name you already use in game windows. Updated the file links on the first post.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 16 Feb 2022, 06:02
@eri0o

Thanks for updates. Please integrate unicode last version (by CW) too. I tested it and the result was correct for showing symbols on Android.

@Crimson Wizard

Did you test it on the device too? If yes, Do you have my problem too?
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Crimson Wizard on 16 Feb 2022, 08:46
Quote from: Mehrdad on 16 Feb 2022, 06:02Please integrate unicode last version (by CW) too.

Please note that we cannot integrate it with the official Android port yet, as unicode feature is not ready; I'm planning to work on it properly soon. We may only post a test version which merges unicode with Android, but it will not be guaranteed to be final, and should be used to create actual game releases.
Currently you may use the existing method of putting unicode in game - using the translations.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 16 Feb 2022, 22:35
I am working on a keystore generation GUI... It will be a little while before everything is rightly working but...

[spoiler](https://i.imgur.com/H1f0t2w.png)[/spoiler]
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Joseph DiPerla on 17 Feb 2022, 02:22
Wow nice! This is shaping up to be a great Android Development tool.
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: Mehrdad on 17 Feb 2022, 06:00
Quote from: Crimson Wizard on 16 Feb 2022, 08:46

Please note that we cannot integrate it with the official Android port yet, as unicode feature is not ready; I'm planning to work on it properly soon. We may only post a test version which merges unicode with Android, but it will not be guaranteed to be final, and should be used to create actual game releases.
Currently you may use the existing method of putting unicode in game - using the translations.


OK. Sure. Thanks for your hardworks


@eri0o

Create keystore is so fantastic. Great feature!. Nice job!
Title: Re: [EXPERIMENTAL] Android Build in the Editor
Post by: eri0o on 19 Feb 2022, 17:47
Finally managed to add the Keystore Generation in the Editor.

I updated the links on the first post. Now in the Editor Preferences, there is a new Tab called Android!

In this tab, you can set JDK path, SDK path, and keystore information. If JDK and SDK are set correctly, test should indicate that they are found.

There is also now a button Generate Keystore where you can write your keystore information and generate one. After it's sucessfully generated, if you click OK, it will fill your preferences settings with this information, if you click cancel, then nothing happens. After you also click OK in the Preferences, settings are applied and  new builds will use the newly set keystore. I tested a bunch, but if you find something wrong, please report.

Edit: did a few improvements on this pane, updated to v4.

I think the only part missing now is getting the icons in place, once that is done, the building part should be alright and then once any merging issues are fixed I will look into touch (https://github.com/adventuregamestudio/ags/issues/1538) input details. Probably in a new thread...

Edit2: finally got icons working! Updated it to v5

Now I only expect bug fixing in this. The features I meant to have at this time with Android Building are all there.

Edit3: renamed Package Name to App ID, in v6. This is to match more recent android documentation that now uses Application ID when referring to it.

I also updated the screenshots and text in the first post.

Edit4: Ok, updated it to v7, now it only keeps the cmd.exe screen if the build fails for some reason. Successful builds will automatically close and report the build success.

Edit5: disabled Gradle daemon by default, but added an option to turn it back on. I highly recommend turning it on, specially if you intend to build to android lots of times. Version is now v8

@Mehrdad, have you ACTUALLY tested with Software mode? Can you confirm by using the setting and confirming with Ctrl+v that you have the same graphical glitch with both Software and OGL renderers? I can't reproduce, but I am trying to figure out what could be the case - haven't actually figured nothing yet...
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 26 Feb 2022, 03:01
v9, probably final revision. Makes the app not require any permission at all since all the game is inside the app and assets packaged in the game itself, there's no need to external disk access.

(https://i.imgur.com/uJXJ0vJ.png)
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Mehrdad on 26 Feb 2022, 14:17
@eri0o
Android Build: ANDROID_HOME is not a valid SDK path. Can't find sdkmanager.

I hadn't this problem in previous builds. SDK path is correct
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 26 Feb 2022, 15:51
What do you mean SDK path is correct? Which Android Studio version you are using? What's the used path? Where's your sdkmanager.bat?
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Mehrdad on 26 Feb 2022, 16:00
My SDK path is:  E:\Archive\Softwares\android-sdk-windows\android-sdk-windows
JDK: C:\Program Files\Android\Android Studio\jre

It was ok in previous versions and I got apk but I have this error now!
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 26 Feb 2022, 16:32
this is weird... Do you have a directory that looks like the one below? I need to figure out where is the sdkmanager.bat in your install.

(https://i.imgur.com/FgQYngP.png)

Did you downloaded the android sdk by hand? If you can't find the sdkmanager.bat file above, do you remember the link of where you got it? (or if it's size is not too unwieldly, if it's possible to share it through some filesharing way...)
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Mehrdad on 26 Feb 2022, 16:43
No I haven't this derectory.Yes, I downloaded the android sdk by hand.
I haven't sdkmanager.bat. I have SDK manager.exe in the same directory that I mentioned
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 26 Feb 2022, 16:58
So sdkmanager.exe is at the root of that directory? Can you pass me a list of directories right in that directory? (maybe there's a cmdline-tools named directory there...)

Can you also tell me your Android Studio version?
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Mehrdad on 26 Feb 2022, 17:10
Yes, it's in root directory

(https://www.uplooder.net/img/image/82/f5291b8b753be2a0631d058bfb0d51e6/1212.png)




Android Studio 3.3.2
built on February 16, 2019
JRE: 1.8.0_152-release-1248-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 26 Feb 2022, 18:15
So this is an older version than the one I was prepared to support, this is before the version naming changes - newer is not 4, they've abandoned that version scheme for one that reflects year (of the base Intellij version or something), stable is 2021 for example.

To be honest the best thing I can think of is to avoid any error checking in ags side at build time and rely in gradle to do it's thing. But it's error reporting is often cryptical. So maybe an option to avoid sanity checking.

I am not sure yet on what to do and come up with something that works but not breaks for others. Supporting many android studios at the pace Google is updating things it's practically a full-time job, so going with only latest version of AS was the compromise I could keep up.
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Mehrdad on 27 Feb 2022, 05:57
That error is in AGS editor and not when it make build.

(https://www.uplooder.net/img/image/59/54ec6c0486338060ba3c94271c1b149a/Untitled.png)
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Crimson Wizard on 27 Feb 2022, 06:09
@Mehrdad, have you set an actual path to android sdk in the Preferences window?
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Mehrdad on 27 Feb 2022, 06:52
Quote from: Crimson Wizard on 27 Feb 2022, 06:09
@Mehrdad, have you set an actual path to android sdk in the Preferences window?


Yes, Actually I get apk before. It says this message in the new version
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 27 Feb 2022, 11:00
Sorry, just to explain, this sdkmanager.exe doesn't exist anymore, this was a previous sdkmanager that had even a graphical interface. In recent versions the sdkmanager is a Java library made of libraries under the cmdline-tools/lib or tools/lib, with an entry point file named sdkmanager.bat, that partially makes up the API. The actual files behind the sdkmanager changes between command line tools and the Android Studio command line tools.

I made everything accounting for the files and SDK installed by the latest Android Studio. The command line tools and Android Studio from Mehrdad are at least three years old... And the new versions are a bit different too, because they expect now that the user will place the directories in the right place manually. It's very tricky to assemble everything by hand, I really would prefer to not support that - I can seriously spend a lot of lines describing how to glue things together, but everything will be very brittle on each update...
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Mehrdad on 27 Feb 2022, 12:44
It's sad news for me. Google doesn't support  IP Iran at all and we can't access to last updates in Android Studio. The only way was manual SDK and so on that we could get it from our sites.
Anyway, updates don't work with VPN and VPS even and google knows them!!
Actually, I can't get apk anymore. If I found any way let you know.
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 28 Feb 2022, 14:06
for now you can create a directory named tools at the root of your android sdk, then create a directory named bin inside it and then an empty text file there called sdkmanager.bat and it will work. I am relying on sdkmanager to update/verify installation of things, so this will work as a temporary proxy. Recap, create an empty text file in ANDROID_HOME/tools/bin/sdkmanager.bat.

I am still thinking on what to do for a prettier way... My premise was to rely on current Android Studio and docs, older versions everything was very confusing... Now it's just... Confusing.
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Mehrdad on 28 Feb 2022, 17:08
I had tools directory so i made "bin" and "sdkmanager.bat" : 
E:\Archive\Softwares\android-sdk-windows\android-sdk-windows\tools\bin

And the same message in AGS editor. Where is my wrong?
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 28 Feb 2022, 17:39
Did you actually placed the sdkmanager.bat inside the bin directory? If you did that and still get the error then show me a screenshot of your preferences tab in the Editor because there's some missing information.
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Crimson Wizard on 28 Feb 2022, 19:09
@eri0o,
QuoteI am relying on sdkmanager to update/verify installation of things

May these steps be simply considered optional and skipped with a warning?
If Mehrdad had apk created earlier, does not that mean that the building itself worked? Perhaps if sdkmanager is not present, or there's another problem with it, you may simply issue a warning and try continue with building?

My guess is, there may be other potential problems there, e.g. if your script wants to install things, that requires internet connection, if I understand right. What if there's no internet connection.

Maybe it's even worth adding a user preference which tells whether perform this step, as user may want to not connect to the internet or download anything while building the game.
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: eri0o on 28 Feb 2022, 22:43
This is what I suggested above.

Quote from: eri0o on 26 Feb 2022, 18:15
To be honest the best thing I can think of is to avoid any error checking in ags side at build time and rely in gradle to do it's thing. But it's error reporting is often cryptical. So maybe an option to avoid sanity checking.

The suggested fake bat script though should bypass the checking as I mentioned, if that works than adding the suggested checks as mentioned.

But full offline build is not possible, at least once Gradle has to connect and download the Java dependencies. Only after that such offline build would be possible. So instead of going for an offline check (e.g. gradle --offline %TASK%), a separate check is needed for complying with no sdkmanager.

Currently it uses the sdkmanager location to verify that the SDK is in place. So what needs to be done is:

- add a preference option that disables sanity checking, this is easily doable.
- figure a way to not use sdkmanager to check that the SDK is in place and separate dependency installation in some way. (this is harder and may take a while)
- add another preference for turning --offline flag in gradle on with a warning that at least once it needs to be run without such option to cache dependencies (we depend currently on androidx.core). This is easy to do too.

Maybe there's some way to pack the dependencies in a jar with the runtime so instead of getting the runtime as Java files get it as a jar library, but I don't know yet how to do that, when I tried it only packed the compiled Java files and the AGS native library files, not the androidx dependencies.
Title: Re: [EXPERIMENTAL] Android Build in the Editor (v9)
Post by: Mehrdad on 01 Mar 2022, 06:12
Quote from: eri0o on 28 Feb 2022, 17:39
Did you actually placed the sdkmanager.bat inside the bin directory? If you did that and still get the error then show me a screenshot of your preferences tab in the Editor because there's some missing information.

Yes I did
(https://www.uplooder.net/img/image/52/d458fdca306de7512136546258f9a5e0/Untitled.png)