Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Vincent on Tue 10/01/2023 13:30:59

Title: Android Build
Post by: Vincent on Tue 10/01/2023 13:30:59
Hello I am trying for the first time to build a game for Android. I am stuck at the "key store path" and I dont know what I should do exactly.

(https://i.imgur.com/CLZRC28.png)
Title: Re: Android Build
Post by: Khris on Tue 10/01/2023 13:37:51
Pick any or create a folder, like D:\Projects\. Then select that folder using the browse button.
Finally, add "keystore.jks" to the path.
Like in the above example, it should eventually say this in the field:

D:\Projects\keystore.jks

The Android SDK will use this path to create a keystore file.
You can think of it like a "Save As..." path of a newly created file.
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 13:44:17
Thanks Khris, I did what you said but it show two errors, maybe I am doing something wrong:
The first sentence say that the value can't be null.

(https://i.imgur.com/0JXxclK.png)

(https://i.imgur.com/y3VEJdH.png)
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 14:04:43
@Vincent , first, yes this should not crash but report a proper error, but I don't know what exactly is going on so lets check things together here to figure out what is going on.

First thing, to run this, AGS will need some tools to be installed

Have you followed the steps here?

https://adventuregamestudio.github.io/ags-manual/BuildAndroid.html#building-for-android

In the Editor Preferences, the Android preferences there, if I remember correctly, ANDROID_HOME and JAVA_HOME will report a "Found on Config!" message directly in the preferences if they are correct. I need this to find the tool that is used to create the keys.

Spoiler
(https://i.imgur.com/mxomOb8.png)
[close]

https://adventuregamestudio.github.io/ags-manual/EditorPreferences.html#android
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 14:16:36
@eri0o thanks for answering, I've been following the manual and installed all the tools required. When I go to the Editor Preferences I left ANDROID_HOME and JAVA_HOME to be default (as you can see in the first screenshot) is that wrong? I had to choose a path or can I leave them to be default? Also suddenly when I click 'generate keystore' I dont get any message and it show that menu you see in the screenshot which I should fill the keystore path. I created a folder for that path but it just allow me to select a .jks file which I dont know where I should get it.
Title: Re: Android Build
Post by: Khris on Tue 10/01/2023 14:39:24
To clarify, you're supposed to generate the keystore file if you don't already have one. This is what the "Generate keystore" button and that dialog are for. Once you have a keystore file, you can re-use if for all future Android projects, inside or outside of AGS.

I'm not sure why AGS would try and combine the path for the keystore file from two strings in the first place tbh, but you can workaround this if you create the keystore file outside AGS (https://stackoverflow.com/a/15330139), then simply select it in the Android preferences pane.
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 14:40:50
@Vincent does the "Found On Config!" prompts next to these variable names appears in your install, like in the image above?

To use the default you have to set those environment variables in Windows itself, as it needs the environment variables to load that. (you can check this by loading cmd.exe and typing echo %JAVA_HOME% )

The screenshot I am interested is the Editor Preferences but the keystore generating window is obscuring that. I will block that button until the other variables are set correctly.
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 15:10:01
Guys thanks for answering, I'm trying to figure it out how all of this works, thanks for your patience. I think maybe something its missing. I've been trying to search for AppData/Local/JetBrains as it show in your screenshot but can't find any JetBrains. For SDK path I've been trying to follow your screenshot but can't see any "Found On Config!" on both side. In Android studio I've been installing Android 10.0 (Q) should I need anything else?

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

If I use the cmd.exe and type echo %JAVA_HOME% nothing seems to happen at all

(https://i.imgur.com/b8fUra0.png)
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 15:13:23
ok, let's roll back a bit, how did you install Android Studio? Are you using the JetBrain Toolbox or did you install by using a installer somewhere? Can you tell me from where you got it?


Also which version of Android Studio do you have?
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 15:18:50
I downloaded Android Studio from this site which is the first one that pop up on google: https://developer.android.com/studio


Android Studio Dolphin | 2021.3.1 Patch 1
Build #AI-213.7172.25.2113.9123335, built on September 30, 2022
Runtime version: 11.0.13+0-b1751.21-8125866 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 4
Registry:
    external.system.auto.import.disabled=true
    ide.text.editor.with.preview.show.floating.toolbar=false



Is this all correct?
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 15:22:00
OK, so you got from Google. Now, I believe this one installs in Program Files, does the following directory exists in your computer?

C:\Program Files\Android\Android Studio\jre

(if that exists, that should be your JAVA_HOME, you can set it in Editor Preferences)
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 15:28:05
Ok, now the "Found On Config!" it showed on the JDK path by following this: C:\Program Files\Android\Android Studio\jre

What about the SDK path?
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 15:31:52
One thing at a time, let's figure out where that was installed.

First, the default location is usually

C:\Users\vincent\AppData\Local\Android\Sdk

Is it there?
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 15:34:57
Yes C:\Users\Utente\AppData\Local\Android\Sdk is there
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 15:36:45
Cool, so you can just use this directory there for the SDK path and a Found On Config! should appear.

In the previous message you sent here https://www.adventuregamestudio.co.uk/forums/index.php?topic=60517.msg636652579#msg636652579 (https://www.adventuregamestudio.co.uk/forums/index.php?topic=60517.msg636652579#msg636652579), on top of that window it should be a textbox that says SDK Path: and follows with a directory, so you can always check there in case you need or have installed in a different place.
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 15:38:56
This is strange because I am using that path: C:\Users\Utente\AppData\Local\Android\Sdk but it doesn't show the "Found On Config!"

(https://i.imgur.com/6zdR3ms.png)
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 15:46:43
That's interesting, I need a fresh install of that version to check.

Google documentation says some things are in specific directories in their SDK, but at the time I made this, the documented locations were incorrect and I used what was true for my Android Studio installation at the time - I also checked previous versions and they matched.

My guess is they finally moved things to the correct place.

The incorrect place of the SDK Manager that was before, and where we look into in AGS Editor was in tools\bin\sdkmanager, inside the SDK directory.

@Vincent unfortunately, if this is the case, this means that I need to fix this before you can proceed.

Also, just checking, the correct path should be:
cmdline-tools/latest/bin/sdkmanager

Reference: https://developer.android.com/studio/command-line/sdkmanager

Inside the SDK directory.

The problem was that the SDK installed by Android Studio didn't used to have the SDK Manager there, only if you downloaded separately, but then it wouldn't work with Android Studio tools.
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 15:49:37
So if doesn't appear the "Found On Config!" for SDK path I can't try to build it right?

EDIT: ok no problem btw I can't find any of this inside the SDK directory "cmdline-tools/latest/bin/sdkmanager"

This is what I have inside the SDK folder:

(https://i.imgur.com/FdRdIj2.png)
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 15:51:38
I think it won't work. I added some more information in my previous post, please read.

Also, just please, check that is indeed the SDK path that is pointed by Android Studio. The problem I had when making this feature is these weren't matching.

I copied the behavior from Game Maker: https://help.yoyogames.com/hc/en-us/articles/115001368727-Setting-Up-For-Android
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 15:53:17
Quote from: Vincent on Tue 10/01/2023 15:49:37So if doesn't appear the "Found On Config!" for SDK path I can't try to build it right?

EDIT: ok no problem btw I can't find any of this inside the SDK directory "cmdline-tools/latest/bin/sdkmanager"

So Google invented a new place to put this that doesn't match their documentation. Awesome, I will check later what they did on this Android Studio version to match in the Editor.
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 15:59:29
Quote from: eri0o on Tue 10/01/2023 15:51:38Also, just please, check that is indeed the SDK path that is pointed by Android Studio. The problem I had when making this feature is these weren't matching.

You mean this?
(https://i.imgur.com/okytLD7.png)

Also regarding this reference "Reference: https://developer.android.com/studio/command-line/sdkmanager"
Should I do all of that to make it work?
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 16:12:11
It looks like the path is correct, I noticed that Game Maker also doesn't support this latest version of Android Studio (they are on Chipmunk) and reading the Android Studio Dolphin release notes they mention they changed something in the sdkmanager.

In this screen of android studio where there are some packages and things, you kinda don't need to click anything because once AGS Editor has the sdkmanager it can download things as needed using it - each six months Google changes some requirements for submitting to play store and I thought it was easier to just upgrade whatever was needed in AGS Editor itself and have the sdkmanager be used by it to automatically get it.

So in theory AGS doesn't really need SDK Manager to build the game, and if I am not mistaken you can make an empty file named sdkmanager and place in tools\bin\sdkmanager (creating the directories as needed) and AGS tries to build things - but it can fail if it doesn't find something the project needs.

QuoteShould I do all of that to make it work

No, don't follow their docs, they are wrong. I will check this tonight.

Android Studio already has those command line tools somewhere, the challenge is figuring out where.

If you don't use the Android Studio to install Android related things the environment gets way too confusing too fast, so the best thing is always figure out how Android Studio is working.
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 16:25:45
Thanks for taking the time to see all of this. What you mean by creating an empty file? Also as you can see in the previous screenshot I dont have these path on the SDK folder:  tools\bin\sdkmanager I'd like to try and see if Ags can compile the same
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 16:52:18
Just checking

In the Building for Android topic in the manual, you did went through all the 4 steps of the Android Studio setup there is there, right?

https://adventuregamestudio.github.io/ags-manual/BuildAndroid.html#building-for-android


You met this screen too?:
(https://adventuregamestudio.github.io/ags-manual/images/android_install_step05.png) (https://adventuregamestudio.github.io/ags-manual/images/android_install_step05.png)


Spoiler
You can create an empty file in several ways, you can save an empty text file with notepad and then just rename it entirely to sdkmanager (the file will have no extension)

You can also use the search inside that directory to see if it's there somewhere.

Ah, a question, have you installed anything through the Android Studio SDK screen you showed, that asked you to accept some license? I remember now there was this license thing sometime ago, but I think sdkmanager would still be found in the place it was in  Android Studio Chipmunk

Also, an alternative way is to use JetBrains Toolbox, it enables downloading multiple versions of Android Studio and having them side-by-side, I think it's still possible to download Android Studio Chipmunk using it - I could not find it easily in Android Studio website, but I use JetBrains Toolbox for this.
[close]
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 17:18:02
Well, I think I went through all the 4 steps of the manual. When I went to "Android SDK" I only selected Android 10.0(Q) and clicked ok but it didnt showed this screen:

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

By the way the Android 10.0(Q) has been installed successfully as they say. I've been met that screen too about licensed and I accepted all (I can't remember if I installed something on that screen but I dont think). I've been trying to use the search bar inside the SDK folder and looking for the sdkmanager but can't find anything...

Idk what should I do next, should I create that empty file and then give that as a path for SDK? or should I try to download JetBrains Toolbox?
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 18:52:56
For the specific version of Android Studio you have I don't know what to do until I have made a clean installation of it somewhere and experimented with it.

If you can use an older version, it should work, I tested up to Chipmunk. This is as much as I can say now  :(
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 19:22:00
This isn't urgent I just wanted to give it a try to see how it all worked. Basically it just miss the sdk path with the version I have of android studio (which I think is the newest one because I just download it today and I dont feel like installing an old version) however as you saw early I followed the correct path in the editor preferences but it doesn't show the "Found in Config!" for the sdk path. However I hope you can look into it soon.
Title: Re: Android Build
Post by: eri0o on Tue 10/01/2023 20:56:00
There was at least four big Android Studio updates since I made the feature.

If you want to get to it asap I recommend using JetBrains Toolbox and downloading the previous version, Chipmunk, there's simply no way I will be able to keep up with Google forever and desync will eventually happen - as it did now.
Title: Re: Android Build
Post by: Vincent on Tue 10/01/2023 21:26:54
Ok thanks again for all the support, were do I should get all of this? Do you have any recommended links?
ps: also I think the manual should be a bit revisited in this case because maybe someone will download a new version of Android studio and have my same problem

edit: I've downloaded JetBrains Toolbox and looked for Chipmunk on it but I found nothing