[MERGED] Android Build in the Editor

Started by eri0o, Tue 08/02/2022 21:44:30

« previous - next »

eri0o

Android Build in the Editor


⚠️⚠️This feature is merged and available in 3.6.0 releases⚠️⚠️


running on your computer may have visual differences ... (I am too lazy to update this gif)

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


  • Install Android Studio, the latest version available
  • Note down the directories it is installed (probably C:\Program Files\Android\Android Studio) and where it installed the Android SDK (probably C:\Users\YOURUSERNAME\AppData\Local\Android\Sdk)
  • open AGS Editor and either create a new game or load a copy of a game you want to test. Don't use your actual game files with this editor since it will add information to your project settings that are not compatible with other 3.6.X versions.
  • On Editor preferences, Set JAVA_HOME to where your JDK is installed, if you have Android Studio, it' s probably C:\Program Files\Android\Android Studio\jre
  • On Editor Preferences, Set ANDROID_HOME to where the Android SDK was installed, it probably is C:\Users\YOURUSERNAME\AppData\Local\Android\Sdk
  • Still on Editor Preferences, set your Android Keystore information. If you don't have a keystore, use the Generate Keystore button. On the keystore generation screen, everything under Certificate is optional.
  • Go in general settings, find the Android entry there and adjust as needed(aab, APK, ...), then on build, select Android among the platforms
  • Hit Build Exe in the Editor and wait things to happen. This will take a lot of time on the first time since it needs to install a lot of things, it should be much faster afterwards

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):


  • icons/android/mipmap-mdpi/ic_launcher.png 48x48 pixels, RGBA png icon
  • icons/android/mipmap-hdpi/ic_launcher.png 72x72 pixels, RGBA png icon
  • icons/android/mipmap-xhdpi/ic_launcher.png 96x96 pixels, RGBA png icon
  • icons/android/mipmap-xxhdpi/ic_launcher.png 144x144 pixels, RGBA png icon
  • icons/android/mipmap-xxxhdpi/ic_launcher.png 192x192 pixels, RGBA png icon

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.
FAQ






  • Q: I am missing the Android SDK!
    A: after installing Android Studio, load Android Studio and click in the top menu in Tools, and then in SDK Manager, at top, hit Edit



    In the next screen, set the adequate location and hit next.


    You can hit next here, just note down that the SDK Folder here is what is set as ANDROID_HOME in the Editor preferences, and JDK Location is the JAVA_HOME on the Editor preferences. <<<<


    And then it comes one thing you have to do, if you want to use it, you need to accept the licenses! There are two licenses you need to accept in this screen, so scroll down and hit accept, switch to the next one, scroll down again, and hit accept again.


    We are going to be using SDK 29 in here for now, so if something complains about it, make sure to comeback to the SDK managed and find and click in Android 10 (Q), API Level 29 and then proceed to installing it. If you don't, AGS Editor may try to download and install it anyway if needed when building your app for the first time, after ANDROID_HOME and JAVA_HOME are set!






  • Q: I installed Android Studio using JetBrains Toolbox! But I can't find it... What do I set in ANDROID_HOME ?
    A: OK, if you did this way, the toolbox entry of Android Studio has an entry to show it in file explorer. If you can't find it, it usually uses a directory similar to below:
    C:\Users\MYUSERNAME\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\211.A_TON_OF_NUMBERS\jre





  • Q: How do I set the screen orientation or rotate it?
    A: Screen Rotation has to be configured in Default Setup, currently there are three possible options: Unlocked (player may rotate device screen freely if he unlocks it), Portrait (game can only be vertically oriented) and Landscape (game screen is horizontally oriented). Default is Unlocked.






  • Q: Why is my app name app-mygame-release.apk? Can I change this name?
    A: You did not change the property Android App ID in General Settings. Set it to something like com.incredibleproductions.indianagame and you will get app-indianagame-release.apk.






  • Q: I got a "validateSigningRelease FAILED" message and my build did not work...
    A: It's possible that the keystore was not set, if that is the case go into Preferences, and on Android tab set the correct keystore information. If you don't have a Keystore, please generate one using the Generate Keystore button, and click OK after successfully generating one.







  • Q: Build is a bit slow, can I do anything to speed it up?
    A: In Editor Preferences, under Advanced tab, in Android, select Use Gradle Daemon and mark it true.




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):

[close]

Mehrdad

#1
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
My official site: http://www.pershaland.com/

eri0o

#2
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.

Crimson Wizard

#3
Quote from: eri0o on Wed 09/02/2022 07:26:00
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 Wed 09/02/2022 07:26:00
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.

eri0o

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.

Laura Hunt

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?

eri0o

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.

Mehrdad

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
My official site: http://www.pershaland.com/

Crimson Wizard

#8
Quote from: eri0o on Wed 09/02/2022 08:37:38
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 Wed 09/02/2022 08:37:38
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.

Mehrdad

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.
My official site: http://www.pershaland.com/

eri0o

#10
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.

Crimson Wizard

The Editor combining Android + Unicode may be downloaded from here:
https://cirrus-ci.com/task/5505374429118464

Joseph DiPerla

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.
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

eri0o

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. :/

Crimson Wizard

#14
Quote from: eri0o on Thu 10/02/2022 09:02:34
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

eri0o

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.

Crimson Wizard

#16
Quote from: eri0o on Thu 10/02/2022 10:28:38
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.


eri0o

#17
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!

eri0o

@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.

Laura Hunt

Unfortunately, this did not work for me. First I got the following error:



And then on subsequent tries, this one:



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.

SMF spam blocked by CleanTalk