Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro Devlopment on Andoid

This thread is locked; no one can reply to it. rss feed Print
Allegro Devlopment on Andoid
nshade
Member #4,372
February 2004

So I have a game that is written in pure C and only uses stdio.h, math.h and Allegro as my libraries. Right it it compiles under Visual Studio/Windows and GCC/Linux with no warnings, so it's as "pure" as it's going to get.

My goal was to port this to Android and iOS as it's interface benefits the most from a touch screen. I was porting this game from DOS and one of my goals was to get it into the most portable shape possible so generic C was the key. (With Allegro as the game lib)

I looked at the wiki for Allegro development for Android it looks outrageously complicated, and it's asking for... java?

I see that there is something called "Android Studio" which like an all in one solution. Any tips on how to start this?

Elias
Member #358
May 2000

This worked at some point: https://github.com/liballeg/android

Unfortunately Android Studio changes a lot between versions so I probably need to update it. But if it works then at least getting an initial sample app up and running should be easy. The rest is then just figuring out the folder structure and some minor things like the icon and store description. It's also not too hard integrating Android Java APIs, like the touch keyboard or Google Play - since you can just call into Java code from C code.

--
"Either help out or stop whining" - Evert

nshade
Member #4,372
February 2004

Thank you, that has helps so much...

===EDIT===

Location for cmake data for Android Studio 3:

set(NATIVE_LIB native-lib)
set(JNI_FOLDER ../../../../../transforms/stripDebugSymbol/debug/0/lib)
include(build/intermediates/merged_assets/debug/mergeDebugAssets/out/jniIncludes/allegro.cmake)

(I found it :))

Elias
Member #358
May 2000

I wish they would come up with a standard way to include NDK components in a maven repository. I'm almost tempted to just remove it and instead force you to download the .aar and .so and .h files separately. But the above way almost works :(

--
"Either help out or stop whining" - Evert

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I'm gonna borrow this thread since I have the same topic to discuss.

I created a new empty activity configured as described in https://github.com/liballeg/android , and it mostly works.

I'm having trouble getting it to find the JNI_INCLUDE folder and allegro.cmake though, or something else is wrong. It keeps failing on line 18 of allegro.cmake, which means the .so file was not found. I'm sure I set the JNI_INCLUDE directory correctly, but it still doesn't work.

So, these lines :

set(NATIVE_LIB native-lib)
set(JNI_FOLDER ../../jni)
include(libs/allegro5-release-5.2.4.1A/assets/jniIncludes/allegro.cmake)

don't work. That's exactly where everything is located after I unpacked the .aar file for allegro.

This is the error I'm getting :

Build command failed.  
Error while executing process E:\AndroidSDK\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Marc\AndroidStudioProjects\HelloAllegro\app -BC:\Users\Marc\AndroidStudioProjects\HelloAllegro\app\.externalNativeBuild\cmake\debug\mips -DANDROID_ABI=mips -DANDROID_PLATFORM=android-15 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Marc\AndroidStudioProjects\HelloAllegro\app\build\intermediates\cmake\debug\obj\mips -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=E:\AndroidSDK\ndk-bundle -DCMAKE_CXX_FLAGS=-std=c++11 -frtti -fexceptions -DCMAKE_TOOLCHAIN_FILE=E:\AndroidSDK\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=E:\AndroidSDK\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}  
CMake Error at libs/allegro5-release-5.2.4.1A/assets/jniIncludes/allegro.cmake:18 (message):  
-- Configuring incomplete, errors occurred!  
See also "C:/Users/Marc/AndroidStudioProjects/HelloAllegro/app/.externalNativeBuild/cmake/debug/mips/CMakeFiles/CMakeOutput.log".

It gives the same error for every architecture, and CMakeOutput.log is not helpful to me.

Elias
Member #358
May 2000

Where (absolute filesystem path) is allegro.cmake located?

--
"Either help out or stop whining" - Evert

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

It's under c:\users\me\AndroidStudioProjects\HelloAllegro\app under

libs/allegro5-release-5.2.4.1A/assets/jniIncludes/allegro.cmake

EDIT

allegro.cmake#SelectExpand
1get_filename_component(ABI ${CMAKE_BINARY_DIR} NAME) 2set(base ${CMAKE_CURRENT_LIST_DIR}) 3 4macro(standard_library NAME) 5 string(TOUPPER ${NAME} UNAME) 6 find_library(LIB_${UNAME} ${NAME}) 7 target_link_libraries(${NATIVE_LIB} ${LIB_${UNAME}}) 8endmacro() 9 10macro(allegro_library NAME) 11 string(TOUPPER ${NAME} UNAME) 12 set(path ${base}/${JNI_FOLDER}/${ABI}/lib${NAME}) 13 if(EXISTS "${path}-debug.so") 14 set(LIB_${UNAME} ${path}-debug.so) 15 elseif(EXISTS "${path}.so") 16 set(LIB_${UNAME} ${path}.so) 17 else() 18 message(SEND_ERROR "${path}.so does not exist") 19 endif() 20 target_link_libraries(${NATIVE_LIB} ${LIB_${UNAME}}) 21endmacro() 22 23include_directories(${base}/${ABI}/include) 24allegro_library(allegro) 25allegro_library(allegro_acodec) 26allegro_library(allegro_audio) 27allegro_library(allegro_color) 28allegro_library(allegro_font) 29allegro_library(allegro_image) 30allegro_library(allegro_primitives) 31allegro_library(allegro_ttf) 32standard_library(m) 33standard_library(z) 34standard_library(log) 35standard_library(GLESv2)

EDIT
I pretty much solved it. It was trying to build the mips and mips64 architectures, which aren't supported, nor do they come with allegro's binaries. To fix this, I changed my app/build.gradle file and added this :

android {
    buildTypes {
        all {
            ndk {
//                abiFilters "mips" , "mips64"
                abiFilters "arm64-v8a" , "armeabi" , "armeabi-v7a" , "x86" , "x86_64"
            }
        }
    }
}

And now I have a yellow screen fading to red and back. Yay! \o/ ;)

Go to: