SDL port for Android SDK/NDK 1.6

Quickly share your Android Code Snippets here...

Re: SDL port for Android SDK/NDK 1.6

Postby wiliamsmith4444 » Sat Jul 16, 2011 5:23 pm

The "correct way" sound should be implemented is by using AudioTrack Java class and providing some callbacks from C code which will feed it with data.
wiliamsmith4444
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sat Jul 16, 2011 5:00 pm

Top

Re: SDL port for Android SDK/NDK 1.6

Postby wilbefast » Tue Jul 19, 2011 10:45 am

Thanks for the port guys :D I much prefer to work exclusively in C++/SDL than messing around with Java and Android. I have the little Alien Shooter game running on the emulator, and also a few of my own games at a very low frame-rate.

That said I decided to get a physical device so as to test at a reasonable speed. Unfortunately not even the default Alien example works properly on the actual hardware.
Specifically I get a black screen with music and sound effects. No graphics are displayed, probably because of this:
Code: Select all
Call to unimplemented OpenGL API

The error pops up about once a second, probably duplicates culled down from multiple times a frame.

Do I need to install a driver or something? No change to original code, device is a Samsung Galaxy Fit. Please help :shock:
wilbefast
Freshman
Freshman
 
Posts: 4
Joined: Tue Jul 19, 2011 10:39 am

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Tue Jul 19, 2011 3:04 pm

That's kinda strange. Are you sure you've used Git, not the halfyear-old file releases? Do other games work for you? Could you please post a full logcat output somewhere? Alien Blaster is using SDL 1.3, I didn't test it in a while.
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Re: SDL port for Android SDK/NDK 1.6

Postby gjtorikian » Tue Jul 19, 2011 3:06 pm

I have seen that error previously, on my Motorola Cliq. It sounds exactly like it reads: there is a call being made to an OpenGL ES lib that is missing.

Unfortunately, not all Android phones are made the same. A game that didn't work on the Cliq, worked on many other phones.

All I can say is to research around the net to see if your phone is missing some implementations. There's also a free app on the Market that tests your OpenGL ES capabilities. I forgot the name, but if you search for "OpenGL" it should come up.
gjtorikian
Developer
Developer
 
Posts: 46
Joined: Wed May 12, 2010 4:35 pm

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Tue Jul 19, 2011 8:15 pm

SDL port depends mainly on DrawTex GLES extension, which as far as I know should be supported by all devices around, it also is required by the GLES standard. There might be some other GL function missing, like setting up matrix transformation etc, and I would really like to know which one, because there are chances that I can replace it with some other GL call. Also, if that device you have does include Android MArket app then it's the shame, because Google should run some compatibility tests on it before allowing them to use Market.
Could you please try to compile and run glxgears example app, or install TeeWorlds game - it uses it's own GL engine instead of the GL texture wrapper for a video surface which SDL provides.
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Re: SDL port for Android SDK/NDK 1.6

Postby gjtorikian » Tue Jul 19, 2011 8:21 pm

Trust me on this: there are definite bugs with the OpenGL ES filtering and implementation on other devices.

Sometimes the OpenGL extension will be reported as active, but will never exist. Here are some specific cases around the Cliq:

http://androidandme.com/2009/11/phones/ ... pengl-bug/

http://www.google.com/codesearch#Z7DzMN ... ode%5C.com (look for Cliq)

I don't know the specifics of other phones, but I know it's broken for other people. There's also this StackOverflow post: http://stackoverflow.com/questions/2093 ... id-devices
gjtorikian
Developer
Developer
 
Posts: 46
Joined: Wed May 12, 2010 4:35 pm

Top

Re: SDL port for Android SDK/NDK 1.6

Postby wilbefast » Wed Jul 20, 2011 2:59 am

Wow! Thanks for all the replies!

pelya wrote:Are you sure you've used Git, not the halfyear-old file releases?

Euh... actually now that you mention it, I think I'm using the version I grabbed off the SDL website here, because it was one that came with an example. :oops: Is this not the same version?

pelya wrote:Do other games work for you?

I just tried out OpenTyrian and it seems to work perfectly fine on the HW. Guess I'm using the wrong version then. Sorry Peyla - please don't hurt me, anywhere but the face :o Just how old is the one I'm using?

I think I might rebuild my system: it's a confused mess of libraries and APIs right now and I'd like to have a fairly clean testing environment. I might get a newer version of Ubuntu: do you guys have any recommendations? I also heard that there's a faster emulator that can be run from VirtualBox - might be worth looking into.
Should probably also take the time to RTFM: I'll report back on what happens next.

Thanks again for all the help :D
wilbefast
Freshman
Freshman
 
Posts: 4
Joined: Tue Jul 19, 2011 10:39 am

Re: SDL port for Android SDK/NDK 1.6

Postby wilbefast » Sat Jul 23, 2011 4:10 am

Okay - I'm all set up and trying to compile the demo application following the readme. No problems up until this line here:
Code: Select all
william@SATAN:~/Utilities/commandergenius$ android update project -p project/
Error: The project either has no target set or the target is invalid.
Please provide a --target to the 'android update' command.


Perhaps unsurprisingly, skipping the step and going straight into build.sh results in:
Code: Select all
BUILD FAILED
/home/william/Utilities/commandergenius/project/build.xml:49: taskdef class com.android.ant.SetupTask cannot be found
using the classloader AntClassLoader[]


Any ideas?
wilbefast
Freshman
Freshman
 
Posts: 4
Joined: Tue Jul 19, 2011 10:39 am

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Sat Jul 23, 2011 9:32 am

Seems like you did not install Android 2.2 SDK, which is requested by SDL. You may either install it, or specify Android-10 target to the "android update project" command, which is 2.3 SDK you've probably installed
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Re: SDL port for Android SDK/NDK 1.6

Postby wilbefast » Sun Jul 24, 2011 6:08 am

final edit: got this working by commenting out all the offending lines of code. I'm 100% certain this will not create problems at some later stage :shock:

edit: yeah, the problem is that R.java can't be generated so the whole thing grinds to a halt.

Hmm... I have actually always had 2.2 installed, but I reset the target to android-7 and tried again. This time no problems for that step :) but the very end of build.sh still isn't happy. The native code compiles and everything works fine right up to the packaging of the finished product (aapt):

Code: Select all
    [setup] Android SDK Tools Revision 12
    [setup] Project Target: Android 2.1-update1
    [setup] API level: 7
    [setup]
    [setup] ------------------
    [setup] Resolving library dependencies:
    [setup] No library dependencies.
    [setup]
    [setup] ------------------
    [setup]
    [setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (4) is lower than the project target API level (7)
    [setup]
    [setup] Importing rules file: tools/ant/main_rules.xml

-debug-obfuscation-check:

-set-debug-mode:

-compile-tested-if-test:

-pre-build:

-dirs:
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /home/william/Utilities/commandergenius/project/bin
    [mkdir] Created dir: /home/william/Utilities/commandergenius/project/gen
    [mkdir] Created dir: /home/william/Utilities/commandergenius/project/bin/classes

-aidl:
     [echo] Compiling aidl files into Java classes...

-renderscript:
     [echo] Compiling RenderScript files into Java classes and RenderScript bytecode...

-resource-src:
     [echo] Generating R.java / Manifest.java from the resources...
     [aapt] /home/william/Utilities/commandergenius/project/AndroidManifest.xml:2: error: No resource identifier found for attribute 'installLocation' in package 'android'
     [aapt] /home/william/Utilities/commandergenius/project/AndroidManifest.xml:12: error: Error: String types not allowed (at 'configChanges' with value 'mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale|uiMode').

BUILD FAILED
/home/william/Utilities/android-sdk-linux_x86/tools/ant/main_rules.xml:310: null returned: 1


You're probably far too 1337 for IDEs, but I can't help but think some of this stuff would be easier using Eclipse (if less satisfying) :?

edit2: 'installLocation' isn't support for android-7 so I set the build target to android-10 and tried again, now we have a bunch of compile errors

Code: Select all
compile:
    [javac] /home/william/Utilities/android-sdk-linux_x86/tools/ant/main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 10 source files to /home/william/Utilities/commandergenius/project/bin/classes
    [javac] /home/william/Utilities/commandergenius/project/src/MainActivity.java:394: method does not override or implement a method from a supertype
    [javac]    @Override
    [javac]    ^
    [javac] /home/william/Utilities/commandergenius/project/src/Video.java:468: method does not override or implement a method from a supertype
    [javac]    @Override
    [javac]    ^
    [javac] /home/william/Utilities/commandergenius/project/src/Video.java:222: cannot find symbol
    [javac] symbol  : variable ACTION_HOVER_MOVE
    [javac] location: class android.view.MotionEvent
    [javac]          if( event.getAction() == MotionEvent.ACTION_HOVER_MOVE ) // Support bluetooth/USB mouse - available since Android 3.1
    [javac]                                              ^
    [javac] 3 errors

BUILD FAILED
/home/william/Utilities/android-sdk-linux_x86/tools/ant/main_rules.xml:384: Compile failed; see the compiler error output for details.
wilbefast
Freshman
Freshman
 
Posts: 4
Joined: Tue Jul 19, 2011 10:39 am

Re: SDL port for Android SDK/NDK 1.6

Postby paulscode » Tue Jul 26, 2011 10:38 pm

I'm considering using your SDL port for my next project because large portions of it are written for SDL 1.2. However, I would need to know if it is possible to have a component that accesses GLESv2 rather than using the GL texture wrapper for a video surface? Basically I am looking to utilize an SDL 1.2 port for things like audio and input, but not be limited to GLESv1. I basically need to figure out whether it would likely be more work to port my project to the official SDL 1.3 for Android, or to go with your SDL 1.2 port and write in access to GLESv2.
paulscode
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Thu Nov 11, 2010 3:57 pm

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Wed Jul 27, 2011 10:15 am

There is currently on GLES 2 support in my port, however I've considered adding it if someone will request it.
That's not complicated, however it will require some quirks in Java - I think I'll integrate that in a few days, but you can do it yourself and give me the patch if you're impatient.
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Re: SDL port for Android SDK/NDK 1.6

Postby paulscode » Wed Jul 27, 2011 10:49 am

Thanks, if you are planning to add GLES2 in the future when someone requests it, I can't speak for a lot of developers, but it would defintely be helpful for my current project. I'm not impatient, there are plenty of things I can work on in the mean time.

BTW, thanks for all the work you've put into your library. I've used it for several of my projects and not had any issues.
paulscode
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Thu Nov 11, 2010 3:57 pm

Re: SDL port for Android SDK/NDK 1.6

Postby slvn » Thu Jul 28, 2011 8:34 am

Hi Pelya, Hi All,

I have been following this thread for 5 months now, and I find this SDL port to be a great project !
While trying to develop some kind of game for the android platform, I came to read the posts and check the inners of the projet.

I have a few questions for a specialist !

* Does it make sense to start a new "clean" build with the following command : "cd projet && ndk-build clean" ?

* What should be the correct target (or the minimun?) passed to the command android update -p projet -t "android-9"

* Then, what should be the correct AndroidManifest.xml version fields ?

* For some reason (accessing the Asset Manager from JNI), I would like to use the libandroid.so which is in the ndk folder. (for me, it's only in cristax-r5-beta3/platform/android-9/...". (though I have several ndk..).

- adding "-landroid" to application/android.mk solved the linking problems.
- But, at runtime, I have troubles to load the shared library "libandroid.so" needed by libapplication.so
How to force/add this libandroid.so to be present into the Apk ?


Thanks,
slvn
Developer
Developer
 
Posts: 33
Joined: Thu Jul 28, 2011 7:45 am

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Thu Jul 28, 2011 1:46 pm

The correct target should be android-12, I did some changes to the code a while ago but forgot to update AndroidManifest.xml and readme, that's what caused compilation errors, I've fixed that already.

Does it make sense to start a new "clean" build with the following command : "cd projet && ndk-build clean" ?

That won't hurt I suppose, however if you want to cleanup your project from all temporary files I suggest running command "git clean -f -d", it will also remove all your sources, so copy them somewhere.

I would like to use the libandroid.so which is in the ndk folder.

To make the life simpler I've copied that lib to the SDL project - just update your Git repository and add "android" library to the CompiledLibraries inside AndroidAppSettings.cfg

Also I've updated SDL to work with newer CrystaX NDK r5 - please re-download it from the http://crystax.net

The GLES 2 support is coming soon...
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Top
PreviousNext

Return to Code Snippets for Android

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests