For OUYA - Compiling 2.1.4 Android Template

Godot Version

2.1.4

Question

What environment do I need to use to compile the Android export template for Godot 2.1.4?

Why?

To set up a forever-sustainable dev environment for the OUYA game console. Godot 2.1.4 is the last version of Godot to support Android 16. For apps to show their banners in the Play Menu, the Android Manifest needs to include this line
<category android:name="tv.ouya.intent.category.GAME" />
and the 732x412 ouya_icon.png needs to be placed at /res/drawable-xhdpi-v4/. Please correct me if I’m wrong, but I believe these things need to be accomplished during the template-compile process.

What I’ve tried

Attempted to follow the instructions for compiling for 2.1 and 3.0

  • On MacOS 10.11 El Capitan
  • Installed Xcode 8
  • Installed Java 8 and 17
  • Installed the latest Android-SDK Command Line Tools
  • Used Java 17 to install ./sdkmanager “platforms;android-16” “platforms;android-26” “platform-tools” “build-tools;29.0.3”
  • Extract NDK (Tried with r10e, r16b, and r17c)
  • Set ANDROID_HOME, ANDROID_NDK_HOME, ANDROID_NDK_ROOT, and JAVA_HOME (Java 8) paths in ~/.bash_profile
  • Used Python 2.7 to install scons (Tried with 2.5.1 and 3.1.2

When I run scons platform=android target=release android_arch=armv7 I get errors that I am building for an unsupported architecture. It looks like it’s pulling in headers from MacOS that include files that only support x86/x64 and I’m not sure why. scons does recognize Android build support. I am able to compile Godot for MacOS.

Any help, thoughts, or ideas are welcome. I’ve been beating my head against this problem for a few days.

need the exact line what the error said, usually you look for the solution around that error

you actually can check what the Scons actually check from android_arch parameter by looking at SconsBuilder file something like that name in the godot 2.1 folder
if there is armv7 written in that file but somethow scons said there’s no architecture for that. then you will need to check something else

i compiled custom Android export template (release and debug) of Godot 4.1.4 on Windows 10 platform. it looks like you used MacOS for compiling this, expect the unexpected i guess

Thank you for your response. I have since wiped my Mac and am starting over, so I don’t have the exact line at the moment. It had over 20 errors that all looked similar and I only really investigated the first. They were all ‘include’ errors and the first one was something like /usr/include/bin/cdefs.h. I believe all the errors were from this /usr/ folder. They were spread out among many include lines that ran successfully that looked like they were pulling from the Godot source. /usr/ seems to be populated by Xcode.

I’ve looked into Linux and Windows. Windows can’t be forever-sustainable because of reliance on Visual Studio, which I think needs to phone home to operate. Also, it looks like Community 2015 is no longer available and the Docs say to use it or 2013. If Windows can be made sustainable, I’d be happy to switch. Linux would require old versions of the CPP compiler that aren’t easily available anymore, and I’m not savvy enough with Linux to reliably mess with adding and removing repositories, even if I knew which ones I needed. There could be other hurdles with Linux, but that was enough for me.

I’ve ordered a 2015 MacBook Pro that should be more at home running software from 2018, the Godot 2.1 era. I’ve been trying to get this done on a 2008 MacBook and it is terribly slow at trial and error software installations. Hopefully being able to run a later version of MacOS and Xcode will just solve the issue.

I will update here if I have success, I welcome more input and advice. Thank you

I’ve continued testing and am still getting the same errors. I’ve now tried on Mac OS 10.13 High Sierra with Xcode 9.2 - these were the latest and greatest when Godot 2.1.4 was released.

Using a newer Mac with M1 on Sonoma, I am able to build Godot + Android templates for 4.2.2 and 3.5.3.

The errors:

haroldpros-mbp:godot-2.1.4-bh haroldpro$ scons platform=android target=release android_arch=armv7
scons: Reading SConscript files ...
Godot Android!!!!! (armv7) (with neon)
scons: done reading SConscript files.
scons: Building targets ...
[  2%] Compiling shared ==> platform/android/os_android.cpp
In file included from platform/android/os_android.cpp:30:
In file included from platform/android/os_android.h:33:
In file included from ./drivers/unix/os_unix.h:39:
In file included from ./drivers/unix/ip_unix.h:33:
In file included from core/io/ip.h:33:
In file included from core/io/ip_address.h:33:
In file included from core/ustring.h:33:
In file included from core/array.h:33:
In file included from core/typedefs.h:38:
In file included from platform/android/platform_config.h:30:
In file included from /usr/include/alloca.h:27:
/usr/include/sys/cdefs.h:761:2: error: Unsupported architecture
#error Unsupported architecture
 ^
In file included from platform/android/os_android.cpp:30:
In file included from platform/android/os_android.h:33:
In file included from ./drivers/unix/os_unix.h:39:
In file included from ./drivers/unix/ip_unix.h:33:
In file included from core/io/ip.h:33:
In file included from core/io/ip_address.h:33:
In file included from core/ustring.h:33:
In file included from core/array.h:33:
In file included from core/typedefs.h:38:
In file included from platform/android/platform_config.h:30:
In file included from /usr/include/alloca.h:28:
In file included from /usr/include/_types.h:27:
In file included from /usr/include/sys/_types.h:33:
/usr/include/machine/_types.h:34:2: error: architecture not supported
#error architecture not supported
 ^
In file included from platform/android/os_android.cpp:30:
In file included from platform/android/os_android.h:33:
In file included from ./drivers/unix/os_unix.h:39:
In file included from ./drivers/unix/ip_unix.h:33:
In file included from core/io/ip.h:33:
In file included from core/io/ip_address.h:33:
In file included from core/ustring.h:33:
In file included from core/array.h:33:
In file included from core/typedefs.h:38:
In file included from platform/android/platform_config.h:30:
In file included from /usr/include/alloca.h:28:
In file included from /usr/include/_types.h:27:
/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
typedef __int64_t       __darwin_blkcnt_t;      /* total blocks */
        ^
/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'
typedef __int32_t       __darwin_blksize_t;     /* preferred block size */
        ^
/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t'
typedef __int32_t       __darwin_dev_t;         /* dev_t */
        ^
/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'
typedef __uint32_t      __darwin_gid_t;         /* [???] process and gro...
        ^
/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'
typedef __uint32_t      __darwin_id_t;          /* [XSI] pid_t, uid_t, o...
        ^
/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'
typedef __uint64_t      __darwin_ino64_t;       /* [???] Used for 64 bi...
        ^
/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'
typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */
        ^
/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'
typedef __uint16_t      __darwin_mode_t;        /* [???] Some file attributes */
        ^
/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t'
typedef __int64_t       __darwin_off_t;         /* [???] Used for file sizes */
        ^
/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t'
typedef __int32_t       __darwin_pid_t;         /* [???] process and gro...
        ^
/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'
typedef __uint32_t      __darwin_sigset_t;      /* [???] signal set */
        ^
/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t'
typedef __int32_t       __darwin_suseconds_t;   /* [???] microseconds */
        ^
/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'
typedef __uint32_t      __darwin_uid_t;         /* [???] user IDs */
        ^
/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'
typedef __uint32_t      __darwin_useconds_t;    /* [???] microseconds */
        ^
In file included from platform/android/os_android.cpp:30:
In file included from platform/android/os_android.h:33:
In file included from ./drivers/unix/os_unix.h:39:
In file included from ./drivers/unix/ip_unix.h:33:
In file included from core/io/ip.h:33:
In file included from core/io/ip_address.h:33:
In file included from core/ustring.h:33:
In file included from core/array.h:33:
In file included from core/typedefs.h:108:
In file included from core/int_types.h:54:
In file included from /Users/haroldpro/Library/Android/sdk/ndk/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/6.0.2/include/stdint.h:63:
In file included from /usr/include/stdint.h:53:
In file included from /usr/include/sys/_types/_intptr_t.h:30:
/usr/include/machine/types.h:37:2: error: architecture not supported
#error architecture not supported
 ^
In file included from platform/android/os_android.cpp:30:
In file included from platform/android/os_android.h:33:
In file included from ./drivers/unix/os_unix.h:39:
In file included from ./drivers/unix/ip_unix.h:33:
In file included from core/io/ip.h:33:
In file included from core/io/ip_address.h:33:
In file included from core/ustring.h:33:
In file included from core/array.h:33:
In file included from core/typedefs.h:108:
In file included from core/int_types.h:54:
In file included from /Users/haroldpro/Library/Android/sdk/ndk/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/6.0.2/include/stdint.h:63:
In file included from /usr/include/stdint.h:53:
/usr/include/sys/_types/_intptr_t.h:32:9: error: unknown type name
      '__darwin_intptr_t'; did you mean '__darwin_ino_t'?
typedef __darwin_intptr_t       intptr_t;
        ^
/usr/include/sys/_types.h:64:26: note: '__darwin_ino_t' declared here
typedef __darwin_ino64_t __darwin_ino_t;        /* [???] Used for inodes */
                         ^
In file included from platform/android/os_android.cpp:30:
In file included from platform/android/os_android.h:33:
In file included from ./drivers/unix/os_unix.h:39:
In file included from ./drivers/unix/ip_unix.h:33:
In file included from core/io/ip.h:34:
In file included from core/os/os.h:34:
In file included from core/os/main_loop.h:33:
In file included from core/os/input_event.h:34:
In file included from core/os/copymem.h:41:
In file included from /usr/include/string.h:141:
/usr/include/sys/_types/_rsize_t.h:31:9: error: unknown type name
      '__darwin_size_t'; did you mean '__darwin_ino_t'?
typedef __darwin_size_t        rsize_t;
        ^
/usr/include/sys/_types.h:64:26: note: '__darwin_ino_t' declared here
typedef __darwin_ino64_t __darwin_ino_t;        /* [???] Used for inodes */
                         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
scons: *** [platform/android/os_android.os] Error 1
scons: building terminated because of errors.

ok let me check godot 2.1.4 source file first

this line, there’s no android_arch in the SConstruct File, instead there’s this:

so changing it this should work:

scons platform=android target=release arch=arm

so from this documentation


the right commands should be:

scons platform=android target=release arch=arm
scons platform=android target=release arch=arm64
cd platform/android/java
# On Windows
.\gradlew build
# On Linux and macOS
./gradlew build

if above works, someone need to update this Godot 2.1’s Compiling for Android Documentation

Those commands did not work for me, but I found a solution!

Starting with 2.1.4-stable source, replace /platform/android/platform_config.h and /platform/android/detect.py with those found in commit c064768.

With this change, I was able to build the Android template for use in the released 2.1.4-stable Godot.app.

Tested with:
-Mac OS 10.11.6/Command Line Tools for Xcode 8.2
-Mac OS 12.7.5/Command Line Tools for Xcode 14.2
-Python 2.7.18
-SCons 2.5.1
-OpenJDK8 (for use with SCons)
-JDK17 (for use with Android SDK Command Line Tools on Mac OS 10.11)
-OpenJDK21 (for use with Android SDK Command Line Tools on Mac OS 12)
-Android SDK Command Line Tools: ./sdkmanager "platforms;android-23" "platform-tools" "build-tools;26.0.1" "ndk;17.2.4988734" "sources;android-23"

For builds to populate on Ouya’s Play Menu, add this intent line with the existing intents in /platform/android/AndroidManifest.xml.template:

<category android:name="tv.ouya.intent.category.GAME" />

Replace the icon.png in the project assets with the 732x412 banner for the Play Menu.

I’ve found Mac OS 12/Xcode 14.2 compiles for Android, but not Mac OS builds. I’m having the best compatibility with Mac OS 10.13 High Sierra + Command Line Tools for Xcode 9.4.1.

To eliminate the need for a newer Java, use Android SDK commandline-tools v8.0, the last version compatible with Java 8.