Ren'Py Incompatibility with android

Black Ram oss

Black Ram
Game Developer
May 10, 2018
582
1,564
HI,
Could you tell me a list of things that make a Renpy game incompatible with Android?
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,383
HI,
Could you tell me a list of things that make a Renpy game incompatible with Android?
A few things that I've run into:
  1. PC and Mac games support video and audio encodings that Android does not. Thus, if you're going to use video or audio files, you have to make sure that they are encoded using Android-supported formats.
  2. In addition, the vanilla Movie class tends to use an underlying "movie" channel, and the Android build will raise an exception if you use that channel and have hardware video decoding enabled. You can get around that by disabling hardware decoding just for mobile platforms. Either that, or you need to configure your own channel and arrange for your movies to play on that channel.
  3. Since Android is touch-based, it doesn't support "hover." Thus, anything you do with "hover" in the user interface never gets triggered on Android.
  4. Again, being touch-based, it's hard to hit small targets. As an example, the default Ren'py Quick Menu can be challenging to hit (at least for my fat fingers) on a smaller Android device. You can work around this by having different screens for Android using the "variant" feature of Ren'py.
 

Black Ram oss

Black Ram
Game Developer
May 10, 2018
582
1,564
A few things that I've run into:
  1. PC and Mac games support video and audio encodings that Android does not. Thus, if you're going to use video or audio files, you have to make sure that they are encoded using Android-supported formats.
  2. In addition, the vanilla Movie class tends to use an underlying "movie" channel, and the Android build will raise an exception if you use that channel and have hardware video decoding enabled. You can get around that by disabling hardware decoding just for mobile platforms. Either that, or you need to configure your own channel and arrange for your movies to play on that channel.
  3. Since Android is touch-based, it doesn't support "hover." Thus, anything you do with "hover" in the user interface never gets triggered on Android.
  4. Again, being touch-based, it's hard to hit small targets. As an example, the default Ren'py Quick Menu can be challenging to hit (at least for my fat fingers) on a smaller Android device. You can work around this by having different screens for Android using the "variant" feature of Ren'py.
thanks, but I was looking for example of the functions not implemented in android.
so only I can create an android version, knowing the code to be removed or modified.
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,383
thanks, but I was looking for example of the functions not implemented in android.
so only I can create an android version, knowing the code to be removed or modified.
Ah so. I don't know of anything native to Ren'py that works on desktops that doesn't work on mobile. (PyTom's done too good a job for what you want. LOL)

What you could look at, however, would be some native Python, possibly implemented as a .py file rather than as a .rpy file, so that it's less "reversable." From Python, you can certainly detect whether you're on mobile or not. The problem is that if you raise an exception out of that code, Ren'py's going to display a stack trace, which will point people in the direction of where the problem is. You'd deter someone at "script kiddie" level, but any competent programmer's probably going to be able undo what you do.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,234
From Python, you can certainly detect whether you're on mobile or not.
To my knowledge, there's no universal way to do this directly with Python. There's , but it don't give you a generic information ; you need to deduct it. Therefore, the most reliable way is to rely on :

Code:
import renpy
[...]

def whatever:
    if( renpy.variant('touch') ): raise Exception( "Do not works with touch screens" )
In the same time it will be the same syntax that the one used to take care of the difference in the Ren'py scripts, which limit the risk of errors.
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,383
To my knowledge, there's no universal way to do this directly with Python. There's , but it don't give you a generic information ; you need to deduct it. Therefore, the most reliable way is to rely on :
In the Ren'py source code, the renpy.android variable is set as follows:
Code:
android = ("ANDROID_PRIVATE" in os.environ)
It is this variable that is later used to insert the android and mobile variants into the variant list. I suspect that it's set as part of the native code used to bring up the Ren'py environment.

In addition, although I haven't tried it, I suspect you could probably look at the path to the game directory and intuit the platform you're on. Ren'py retrieves that via:
Code:
# Returns the path to the Ren'Py base directory (containing common and
# the launcher, usually.)
def path_to_renpy_base():
    renpy_base = os.path.dirname(os.path.realpath(sys.argv[0]))
    renpy_base = os.path.abspath(renpy_base)
    return renpy_base
So, a 100% universal way of figuring this out? Possibly not. But I think one could probably do something.

The problem with all of this, however, is that since the game can be decompiled, it probably wouldn't be too hard for someone to find the offending code and comment it out before building the Ren'py version. People regularly ask about doing something DRM-ish within Ren'py games, but the answer's always the same - the game itself has to be able to read the assets, so anything you do to keep, for example, .rpa files from being manually decompressed can be defeated by someone that looks at what you've done within the game. So, it's "basic script kiddie" protection and nothing really more than that.
 
  • Like
Reactions: anne O'nymous

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,978
16,234
So, a 100% universal way of figuring this out? Possibly not.
I think that it can works as "universal".
While talking about the Ren'py alternative, I was still addressing Python as generically used, which was stupid. It's not some code randomly ported to Android, here the port is done by Ren'py, which guaranty way more stability in the result. By example, there's many way to run Python on Android, but obviously Ren'py don't randomly pick one each time it make a port ; you'll always face the same.
The lockdown (we are ending the fourth week here) start to hit my brain a little too much :(


The problem with all of this, however, is that since the game can be decompiled, it probably wouldn't be too hard for someone to find the offending code and comment it out before building the Ren'py version. People regularly ask about doing something DRM-ish within Ren'py games, but the answer's always the same - the game itself has to be able to read the assets, so anything you do to keep, for example, .rpa files from being manually decompressed can be defeated by someone that looks at what you've done within the game. So, it's "basic script kiddie" protection and nothing really more than that.
Exactly. You can complicate the task, but you can't prevent the uncompilation. And generally, the more you complicate it, the more dedicated will be the guy that will revert it. In top of that, since the said guy was able to uncompile your code, you can easily guess that he'll also be able to find the tricks you used inside.

Anyway, the early years of Internet and the Open Source community proved that the more open you are, the more easily people will accept your decisions regarding what you do in your code. But if you start to hide your code, they will try to find what your really wanted to hide by doing this.
 
  • Like
  • Sad
Reactions: Cul and Rich