Improving the Android build environment

Talk about things that are not making games here. But you should also make games!

Moderators: Bob the Hamster, marionline, SDHawk

Chronoboy
Slime Knight
Posts: 281
Joined: Tue Nov 30, 2010 6:01 am
Location: Canada

Post by Chronoboy »

TMC wrote:In never realised that it had its own unlump routine. The code is so short that I didn't recognise it :)
The lump format is very basic, not many lines of code are needed to extract a lump:

Code: Select all

    with open(game,'rb') as f:
        while 1:
            try:
                fi = getdata(f)
            except:
                break
            size = getlong(f)
            zf.writestr('%s/%s' % (rpgdir,fi), f.read(size))
Bob wrote:Looks awesome so far, but some things will need to change before I can use it to replace the process I am currently using.
I'm glad you approve. Not entirely sure why it would need to support multiple keystores as your build system does. This build system is targeted at the game developers of OHR, and I don't believe they need more than 1 key. Once we introduce this build system as the way to build APKs, you shouldn't need to do another android OHR for a game you personally didn't make. This way, you can focus more of your time and energy into getting the next release of OHR out, rather than sitting in a dark room building APKs.

I did make some basic documentation in the first post I believe.

Fixing the bug you noticed with lump names is pretty easy, as you can tell from the above code. I can have a commit for the fix done very soon.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Chronoboy wrote:Not entirely sure why it would need to support multiple keystores as your build system does. This build system is targeted at the game developers of OHR, and I don't believe they need more than 1 key. Once we introduce this build system as the way to build APKs, you shouldn't need to do another android OHR for a game you personally didn't make. This way, you can focus more of your time and energy into getting the next release of OHR out, rather than sitting in a dark room building APKs.
This tool will make it way easier for people to build their own apks, but there will always be some bigger-than-zero number of people who need help, so I want to still be able to help them.

Also, games that have already been published to google play or ouya's store must keep using the keys they are using now. You can't change keys in an upgrade, so even for me to continue supporting my own games, I am going to need multiple key support.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Come to think of it, we probably can't trust people to backup their keys!
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Yeah, backing up keys is a really big deal. If you lose your key, you can't update your game ever again.

Losing your keystore file is even worse than losing the rpg file itself.
User avatar
Taco Bot
Meat, Cheese, and Silicon
Posts: 484
Joined: Fri Jul 18, 2014 12:15 am
Location: Santa Cruz
Contact:

Post by Taco Bot »

(Sorry for the 1 year necro)

I tried the instructions given in this thread using the most recent commit of the program, and I'm getting an error when I try to build my apk:

Code: Select all

BUILD FAILED
/home/xtaco/Programs/tools/ohr-android/android-sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/home/xtaco/Programs/tools/ohr-android/android-sdk/tools/ant/build.xml:734: Class not found: javac1.8
And the line in question (734) has this to say:

Code: Select all

fork="${need.javac.fork}">
I've tried with both openjdk-8 and the official Oracle JDK, but neither worked. I feel like the Android SDK might be missing something?

I've got next to no experience with Java or Android development, so this is mostly gibberish to me... :/
Sent from my iPhone
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Java and the Android build system are both gibberish to me too.

I tried googling that error, and it appears that the error message is confusing, it's actually the javac1.8 binary that is missing. Although actually I don't have any binary named something like javac1.8, I only have javac. (And I have openjdk-7u9.)

Do you have a 'javac' binary in your path? I found someone who wrote that a OpenJDK install may be just the JRE (runtime environment), not the JDK. The package you actually need is different: "It's called openjdk-8-jdk on Debian based distros including Ubuntu, Mint... and java-1.8.0-openjdk-devel on Redhat based distros including Fedora, Mageia..." (source)
Last edited by TMC on Wed Jan 27, 2016 9:06 am, edited 3 times in total.
User avatar
Taco Bot
Meat, Cheese, and Silicon
Posts: 484
Joined: Fri Jul 18, 2014 12:15 am
Location: Santa Cruz
Contact:

Post by Taco Bot »

running "which javac" returns "/usr/bin/javac." And I've installed all of the openjdk-8-* packages...
Sent from my iPhone
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Wait a minute, the error you posted also indicates line 720, possibly a second error? What's the content of lines 720-734 and nearby? The line numbers are different in my copy, because I have an older version of ant.

Tomorrow, I guess, I'll try rerunning 'android.py install-sdk' and see whether it still works for me. Maybe there have also been updates to the original android.py tool that Chrono based his on.
Last edited by TMC on Thu Jan 28, 2016 9:23 am, edited 1 time in total.
User avatar
Taco Bot
Meat, Cheese, and Silicon
Posts: 484
Joined: Fri Jul 18, 2014 12:15 am
Location: Santa Cruz
Contact:

Post by Taco Bot »

Here's a pastebin on lines 718-795 (Tried to get the whole block of xml in there): http://paste.ubuntu.com/14704657
Sent from my iPhone
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

OK, that error has nothing to do with the 'fork' line. That's just the line where the javac xml tag ends.

Realising that, I found a much more promising answer. Check what version of ant you have. You need at least 1.9.1 to compile with java 1.8.
User avatar
Taco Bot
Meat, Cheese, and Silicon
Posts: 484
Joined: Fri Jul 18, 2014 12:15 am
Location: Santa Cruz
Contact:

Post by Taco Bot »

Aha! The ohr-android-sdk-downloady-thing™ downloads "apache-ant-1.8.4-bin.tar.gz"

I downloaded the current binary release of ant from http://ant.apache.org/bindownload.cgi and replaced the "apache-ant" folder with it, and the build was successful!

Thank you so much for your help, TMC! Much appreciated!

The only other problem is that it seems to use the stable release of the ohr, so I need to find a way to update that to a recent daily in order to use some features.[/list]
Sent from my iPhone
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Ah, I updated it to download Ant 1.9.6 in future (unfortunately I couldn't find a permanent download link to the latest version).

If you used the download link that Chrono gave at the beginning of this thread, that's very old indeed. I've just recompiled the pre-built binaries and made some other improvements to the tool. You can download it here:
https://bitbucket.org/kveroneau/ohrrpgc ... /downloads
Just extract on top of your existing copy to avoid redownloading anything.

Please test your game thoroughly before releasing it though, as I built with debug=0, which wasn't working until an hour ago (therefore has had little testing), but should mean it runs faster and produces smaller .apks.

It's still awfully difficult to use. Since I didn't re-read this thread carefully, I found it almost impossible to figure out!
Last edited by TMC on Mon Feb 01, 2016 1:21 pm, edited 2 times in total.
roboman
Red Slime
Posts: 41
Joined: Fri Sep 23, 2011 6:09 pm
Contact:

Post by roboman »

Finally I've generated some apks with a strange mixture of this methods, I've tried to upload to the Google Play the plain, and the unaligned versions, but the Google Play hasn't accepted them yet. I'll try the unsigned version. I wonder what should I do with the files in order to upload them (or any of them). The Google Play says that my apk is in debug mode. Is there a possibility to put it to release mode?
Last edited by roboman on Sat Sep 17, 2016 11:22 pm, edited 2 times in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Do you meant that Google Play rejects the .apks because there is something wrong with them? But doesn't tell you what the problem is? Can you explain what your "strange mixture" is?

I don't think anybody aside from you has actually tried uploading an .apk to Google Play that they created with the ohrrpgce-android tool, although it created working .apks for testing on my own phone. It's still very far from what I would consider as ready for general use, but I do want get it working and ready. (Also, the build of the OHR included with it hasn't been updated since February (i.e. before the Callipygous release).)

You must upload an aligned signed apk, not signed with the debug key.
When you run "android.py build <projectdir> release" you will see the following at the end of the output:
-release-nosign:
[echo] No key.store and key.alias properties found in build.properties.
[echo] Please sign /mnt/common/proj/ohrrpgce-android/bin/KarateFight-1-release-unsigned.apk manually
[echo] and run zipalign from the Android SDK tools.
It looks like there's nothing in ohrrpgce-android to do with signing .apks, but the Android SDK will do so if the key.store and key.alias properties are set in build.xml. build.xml is generated automatically by running "android update project -p . -t android-17 -n <versioned_name>". So to set these properties, it seems you have to create a file name "ant.properties" next to the android.py file, and set the values there:

Code: Select all

key.alias = foo
key.store = bar
Alternatively, you can sign your .apk manually. See http://rpg.hamsterrepublic.com/ohrrpgce ... ase_builds
Last edited by TMC on Sat Sep 17, 2016 11:54 pm, edited 1 time in total.
roboman
Red Slime
Posts: 41
Joined: Fri Sep 23, 2011 6:09 pm
Contact:

Post by roboman »

Finally! I managed to upload my apk to Google Play, which I did formerly with this method. I set the debuggable thing to false in the AndroidManifest.xml with an editor. (It was the APK Editor Pro, if it counts.) Then i manually signed the apk with the help of Java Development Kit and Android SDK, which is found in Android Studio. And that was all the story so far. Maybe nobody tried uploading apk done with ohrrpgce-android tool, but i did, and i am pleased with it. Thank you for the tool, and opportunity, anyway.
Last edited by roboman on Wed Feb 08, 2017 8:39 am, edited 1 time in total.
Post Reply