Author Topic: Let's build for Android!  (Read 1304 times)

Let's build for Android!
« on: 08 Jan 2018, 00:35 »
I will try to explain what I did here, questions will arise, hopefully everything can be answered here and this will allow me to generate a guide.

So first two things are important:
 - Android port of the engine currently doesn't report correctly mouse.isButtonDown, so your game CAN'T BE USING THIS, use if(System.OperatingSystem == eOSAndroid) in your code to work for this.
 - I am using the latest prebuilt APK as libs, those were for the previous stable version, so your game must be built with that AGS.

1. You need to install the latest Android Studio, just download and install. https://developer.android.com/studio/index.html .

2. You will also need JDK, NDK and Android SDK.

3. After installing Android Studio, download the repository I made here: https://github.com/ericoporto/mythsuntold_dungeonhands . This is my modded version of Monkey's Android Studio Project.

4. Open the folder in Android Studio.

5. Building should generate my game .apk!

6. Ok, let's make YOUR game .apk. In the folder Android Studio placed the Sdk, there is a magical tool called jobb. I use Ubuntu, and the tool is in the folder ~/Android/Sdk/tools/bin/ in my computer. If you use Windows, then it's probably in %appdata%\Local\Android\Sdk . (if someone can confirm this information, it would be awesome!). This is just so you can understand what will happen next.

7. In your game Compiled folder, there is a YOURGAMENAME.ags file. Open a cmd.exe (windows) or bash terminal (Linux/OSX). Change Directory to the folder YOURGAMENAME.ags is.

In Windows (untested!)
Code: Adventure Game Studio
  1. cd YOURGAMENAME\Compiled\
  2. mkdir obb
  3. move YOURGAMENAME.ags obb\
  4. %appdata%\Local\Android\Sdk\tools\bin\jobb -d \obb\ -o main.3.com.YOURSTUDIONAME.YOURGAMENAME.obb -pn com.YOURSTUDIONAME.YOURGAMENAME -pv 3
  5.  
   
In Linux/OSX
Code: Adventure Game Studio
  1. cd YOURGAMENAME/Compiled/
  2. mkdir obb
  3. mv YOURGAMENAME.ags obb/
  4. ~/Android/Sdk/tools/bin/jobb -d ./obb/ -o main.3.com.YOURSTUDIONAME.YOURGAMENAME.obb -pn com.YOURSTUDIONAME.YOURGAMENAME -pv 3
  5.  

In the code above, 3 is simply the OBB version number. Every time you change the content of the OBB linked to your APK and release, you have to increase that number - and update in your Android Studio Project accordingly. Also make sure that YOURGAMENAME and YOURSTUDIONAME are correctly updated in your android studio project.

8. In the README there is a line called Setting up the project for your game. I will copy below:

-Update package name:

Open the project in Android Studio, then in the project tree navigate to app/java/com.mythsuntold.osd.scourge.
Right-click on this folder and select "Refactor -> Move...". When prompted, select "Move package 'com.mythsuntold.dungeonhands' to another package" (the default). You may receive a warning that multiple directories will be moved, select Yes. Type the parent name of your package, not the final package name (e.g., com.bigbluecup not com.bigbluecup.game), select "Refactor" and then click "Do Refactor".
Right-click on the new project folder in the project tree (e.g., com.bigbluecup.scourge) and select "Refactor -> Rename". Type the package name for your game (e.g., game), then select "Refactor" and click "Do Refactor".

Finally, delete the com.mythsuntold.dungeonhands folder.

- Update project.properties. This file contains gradle settings related to your project. The application ID, version code, and version name need to be set to match your project settings (application ID is your package name).

- Update project.xml. This file contains resources for your project. The values there are described in that file.

- Update local.static.properties. This file contains local data that should NOT be added to version control (.gitignore will ignore your changes to this file). You need to add your keystore path, alias, and passwords, and optionally the path to your copy of the AGS source (if you are rebuilding the engine native libraries). See the Java docs on keytool or use the Android Studio signing wizard to generate a keystore.

- Update private.xml. This file contains definitions for your RSA public key and an integer-array with bytes for your salt which is used by the ExpansionDownloaderService. These values are necessary if distributing your app via the Google Play Store. The RSA public key is provided in the Google Play Developer Console, and the salt bytes may be any number of values in the range [-128, 127]. You may need to upload an APK without the RSA public key first before the key is provided. That APK should not be public unless the OBB file is embedded.

- Update graphics resources (app/src/main/res). You can use the Android Asset Studio to easily generate graphics for your app, or use your preferred method. Everything in the drawable and various mipmap-* folders should be replaced with your resources.

I made this post with the intent to help Mehrdad, so please try this!

Mehrdad

    • I can help with animation
    •  
    • I can help with characters
    •  
    • I can help with story design
    •  
    • I can help with web design
    •  
Re: Let's build for Android!
« Reply #1 on: 08 Jan 2018, 06:47 »
Great!!!.Nice job, Thanks so much Erio. I'll try it soon ;-D

Re: Let's build for Android!
« Reply #2 on: 09 Jan 2018, 16:24 »
Awesome! I've been looking for a little more hand-holding on this process after having some trouble running through Monkey's guide. Before I get stuck in, can you confirm if this works with games that were built with the latest editor build (3.4.1 December)?

Exciting stuff!

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Let's build for Android!
« Reply #3 on: 09 Jan 2018, 16:54 »
can you confirm if this works with games that were built with the latest editor build (3.4.1 December)?
You cannot build 3.4.1 for Android, until I (or someone else) fix OpenGL code compilation for mobile ports. :/ (Which I hope to address very soon).

Re: Let's build for Android!
« Reply #4 on: 09 Jan 2018, 17:03 »
Ah, drat. Can't win 'em all. Looking forward to that CW, your efforts with the OpenGL side of things have been very much appreciated.

Joseph DiPerla

  • Joseph DiPerla, Adventure Game Creator Wannabe!
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with play testing
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
    • I can help with web design
    •  
Re: Let's build for Android!
« Reply #5 on: 10 Jan 2018, 14:32 »
I know nothing about OpenGL or coding, but it seems you may need to use opengl es to compile for at least android: https://developer.android.com/training/graphics/opengl/index.html

Seems like a rough task. But then again, what do I know?
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

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Let's build for Android!
« Reply #6 on: 10 Jan 2018, 15:16 »
I know nothing about OpenGL or coding, but it seems you may need to use opengl es to compile for at least android: https://developer.android.com/training/graphics/opengl/index.html

Seems like a rough task. But then again, what do I know?

We already have OpenGL coded for Android port (otherwise it would not work at all). But I added some changes for 3.4.1 to make Tinting work (because JJS forgot to add support for that), using shaders, and now I need to find out how to make shaders work with GL ES.
Assuming that may simply be a matter of finding out correct headers and function names, so may take only couple of hours, but I need to study this first.

I keep saying "I need", although all this time I had a secret wish someone else do that, considering there were people already building Android port on their own. ;)

Re: Let's build for Android!
« Reply #7 on: 10 Jan 2018, 17:56 »
CW, I still couldn't understand: is the current master branch supposed to build for Android or it should fail?

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Let's build for Android!
« Reply #8 on: 10 Jan 2018, 18:02 »
CW, I still couldn't understand: is the current master branch supposed to build for Android or it should fail?
It will fail, here is the issue ticket: https://github.com/adventuregamestudio/ags/issues/420

Basically, what we need to do is to find how shader functions (list is given in the ticket) are called in GLES, include proper headers for mobile ports and make proper "#define"s for these functions.
Well, and test that everything is working, ofc.

Re: Let's build for Android!
« Reply #9 on: 10 Jan 2018, 18:46 »
In Android docs I found:

https://developer.android.com/reference/android/opengl/GLES20.html

Doing ctrl+f on each thing from the issue, things look available. I don't know where are iOS docs.

Edit: android moved docs from 'development' to 'developer' and I had a mini heart attack here.
« Last Edit: 14 Feb 2018, 02:39 by eri0o »

Re: Let's build for Android!
« Reply #10 on: 08 Mar 2018, 12:15 »
Nice! Can I have a question that is slightly off-topic? (hopefully just slightly :) )
Android port of the engine currently doesn't report correctly mouse.isButtonDown, so your game CAN'T BE USING THIS, use if(System.OperatingSystem == eOSAndroid) in your code to work for this.
What exactly does it mean, that it's not reported correctly? I'm currently using the function in both my Android projects without a problem, have I missed something?

Re: Let's build for Android!
« Reply #11 on: 06 May 2018, 23:52 »
I don't know how I didn't see this question.

My experience with the Android port was that isButtonDown only reports correctly once the finger is placed in the touchscreen, but then, even if the finger stays in the screen, it doesn't return true anymore - like it would when you do a mouse left click and hold. I saw that iOS Wadjet port does has this behavior - which gets rid of the mouse left click being thrown on finger hold.

This is because the Android port is designed for being able to play existing ags games, and not for making Android games.

Crimson Wizard

  • Local Moderator
  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Let's build for Android!
« Reply #12 on: 10 May 2018, 10:35 »
can you confirm if this works with games that were built with the latest editor build (3.4.1 December)?
You cannot build 3.4.1 for Android, until I (or someone else) fix OpenGL code compilation for mobile ports. :/ (Which I hope to address very soon).


UPD: You now can.

monkey0506

  • AGS Project Tracker Admins
  • Tasting the banhammer. Strangely, tastes like ham.
Re: Let's build for Android!
« Reply #13 on: 06 Jun 2018, 08:07 »
Android\Sdk\tools\bin\jobb ...

The jobb tool distributed with the Android SDK (including latest versions) is not suitable for games over 511 MB. This won't affect most games, but it is something that should be pointed out explicitly.

Additionally, you've committed a lot of binary files into your git repo, and don't even have a .gitignore file. I appreciate the fact that you made an effort to maintain this project (or the steps described therein), but you have missed important steps that obfuscate what you did actually fix from the original git repo. FWIW, I have time and an interest in getting the original repo working, but I can't promise anything definitive as I also have other projects to revisit.
User was banned for this post.

Re: Let's build for Android!
« Reply #14 on: 14 Jun 2018, 12:44 »
Thanks Monkey0506 . I was just trying to make something fast that could work on Windows, but I wasn't very eager to install Android Studio on it... I just used it as an alternative to your plugin for myself, on Android Studio on Linux. :/