0
0

As soon as I link fmodex.so to my app, it crashes when I try to run it on the phone saying that the application has stopped unexpectedly.

I do have android 2.3.3 on my device
I have downloaded the newest version of FMOD for Android
my app is set for platform 9
I have linked -lOpenSLES

and I have tried these two builds, which both compile fine, but wont run:

1) I put the fmodex.so file in "AndroidSDK\NDK\platforms\android-9\arch-arm\usr\lib" and used this makefile:

[code:1o0vdrb9]
LOCAL_PATH := $(call my-dir)

BUILD MAIN APP

include $(CLEAR_VARS)

LOCAL_MODULE := myApplication
LOCAL_ARM_MODE := arm
LOCAL_C_INCLUDES := $(LOCAL_PATH)/FMOD/include \
LOCAL_SRC_FILES := main.cpp

LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lfmodex
LOCAL_STATIC_LIBRARIES := android_native_app_glue

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)
[/code:1o0vdrb9]

2) I stored a copy of FMOD in my project directory and used this makefile:

[code:1o0vdrb9]
LOCAL_PATH := $(call my-dir)

BUILD FMOD

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := fmod
LOCAL_SRC_FILES := FMOD/lib/android-9/armeabi/libfmodex.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/FMOD/include
include $(PREBUILT_SHARED_LIBRARY)

BUILD MAIN APP

include $(CLEAR_VARS)

LOCAL_MODULE := myApplication
LOCAL_ARM_MODE := arm
LOCAL_C_INCLUDES := $(LOCAL_PATH)/FMOD/include \
LOCAL_SRC_FILES := main.cpp

LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -lOpenSLES
LOCAL_STATIC_LIBRARIES := android_native_app_glue
LOCAL_SHARED_LIBRARIES := fmod

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)
[/code:1o0vdrb9]

Can anyone help me out with this?

Thanks, Nick

  • You must to post comments
0
0

Ok, thanks. In the mean time, I managed to get SLES running. Not as pretty as FMOD, but it’ll get the job done for now =)

  • You must to post comments
0
0

We are successfully using FMod on android as a native activity.

I did not write this particular bit of code, but I believe that a native activity is described by a [i:1d0i05ce]single .so[/i:1d0i05ce]. If you require other .so’s then you must explicitly [b:1d0i05ce]dlopen[/b:1d0i05ce] them yourselves – they are [i:1d0i05ce]not[/i:1d0i05ce] automatically found and opened like in other operating systems.

Thus we have a simple "launcher" .so that does nothing but dlopen a series of other .so’s – those being the application.so and libfmodex.so.

  • You must to post comments
0
0

Do the FMOD examples work for you? What about the recording example (it uses level 9 SDK)?

  • You must to post comments
0
0

I tried dlopen, but I still get a crash. I started my app up like this:

[code:3j034wq7]void android_main(struct android_app* app)
{
app_dummy();

if(dlopen("libfmodex.so" , RTLD_NOW) == NULL)
    LogPrint("couldn't load lib");

LogPrint("loaded lib");

....[/code:3j034wq7]

I didn’t even get either of the log messages before the app quit on me

  • You must to post comments
0
0

Is there a step by step in the docs somewhere about how to compile the examples? because no matter which way I import this and that, I can’t get the eclipse project to come out error free..

edit: sorry, I don’t mean comile. I was able to compile the ndk lib for the recording example ok, but I can’t get the exclipse project configured properly =/

  • You must to post comments
0
0

I came across this, and I think I understand what you mean now.

from google IO:
http://www.youtube.com/watch?v=5yorhsSP … ge#t=1441s

he says "Android does not support dynamically loaded libraries that are automatically linked, we don’t do dependency checking. So we have to have a way of loading that other library before native activity kicks off."

so this seems to confirm what you were saying, but his example uses the Java activity. How can I get fmod to load first?

  • You must to post comments
0
0

Ok. I got the recording example to run on the phone. It works fine, but as far as i can tell, my project configuration is the same except that I am using a native glue activity instead of java..does that matter?

  • You must to post comments
0
0

That YouTube link is actually the solution you are looking for.

As they say, you need to load the dependencies for Android (it doesn’t do this itself), hence you need to put some code in before the native activity starts.
So what you need to do is extend the existing Java class that provides NativeActivity with some static code that first loads "fmodex" then loads your code, then point the manifest towards your extended class instead of the provided NativeActivity one.

I have made a super cut down version of the Android NDK NativeActivity example that plays a stream using FMOD. This new example will be available with our next development branch release.

  • You must to post comments
0
0

There are steps on how to run the examples in the getting started guide.

Can you try linking with the logging version of FMOD and report back any logcat output?

  • You must to post comments
0
0

works perfectly now. Thanks again

  • You must to post comments
0
0

Ok, I tried that, but I don’t see anything in here that wasn’t here before. Here is the entire log output this time:

[code:2ml7vv5x]
DEBUG/AndroidRuntime(10337): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
DEBUG/AndroidRuntime(10337): CheckJNI is OFF
DEBUG/dalvikvm(10337): creating instr width table
DEBUG/AndroidRuntime(10337): Calling main entry com.android.commands.pm.Pm
DEBUG/AndroidRuntime(10337): Shutting down VM
DEBUG/dalvikvm(10337): GC_CONCURRENT freed 103K, 69% free 326K/1024K, external 0K/0K, paused 1ms+0ms
INFO/AndroidRuntime(10337): NOTE: attach of thread ‘Binder Thread #3’ failed
DEBUG/dalvikvm(10337): Debugger has detached; object registry had 1 entries
DEBUG/AndroidRuntime(10347): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
DEBUG/AndroidRuntime(10347): CheckJNI is OFF
DEBUG/dalvikvm(10347): creating instr width table
DEBUG/AndroidRuntime(10347): Calling main entry com.android.commands.am.Am
INFO/ActivityManager(115): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.ggames.myApplication/android.app.NativeActivity } from pid 10347
INFO/[POST_RESELECT](471): [spanChange] (o, oldStart, newStart, oldEnd, newEnd)=(android.text.Selection$START@4013cd98,-1,0,-1,0)
INFO/[POST_RESELECT](471): [spanChange] (o, oldStart, newStart, oldEnd, newEnd)=(android.text.Selection$END@401132c8,-1,0,-1,0)
DEBUG/AndroidRuntime(10347): Shutting down VM
INFO/AndroidRuntime(10347): NOTE: attach of thread ‘Binder Thread #3’ failed
INFO/ActivityManager(115): Start proc com.ggames.myApplication for activity com.ggames.myApplication/android.app.NativeActivity: pid=10355 uid=10062 gids={}
DEBUG/dalvikvm(10347): GC_CONCURRENT freed 105K, 66% free 353K/1024K, external 0K/0K, paused 0ms+1ms
DEBUG/jdwp(10347): Got wake-up signal, bailing out of select
DEBUG/dalvikvm(10347): Debugger has detached; object registry had 1 entries
DEBUG/SensorService(115): enable: connection.get() = 0x454e08, (2.3.4)
DEBUG/SensorService(115): enable: get sensor name = BMA150 3-axis Accelerometer
DEBUG/SensorService(115): SensorDevice::activate: handle = 0x0, enabled = 0x1
DEBUG/Sensors(115): Enable akm: en = 1
DEBUG/AK8973(79): Compass Start
DEBUG/SensorService(115): noteStartSensor: uid = 0x3e8, handle = 0x0
DEBUG/SensorService(115): pid=115, uid=1000
DEBUG/SensorService(115): Active sensors:
DEBUG/SensorService(115): BMA150 3-axis Accelerometer (handle=0x00000000, connections=1)
DEBUG/SensorService(115): CM3602 Light sensor (handle=0x00000004, connections=1)
DEBUG/AndroidRuntime(10355): Shutting down VM
WARN/dalvikvm(10355): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
ERROR/AndroidRuntime(10355): FATAL EXCEPTION: main
ERROR/AndroidRuntime(10355): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ggames.myApplication/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/data/com.ggames.myApplication/lib/libmyApplication.so
ERROR/AndroidRuntime(10355): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1821)
ERROR/AndroidRuntime(10355): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1842)
ERROR/AndroidRuntime(10355): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
ERROR/AndroidRuntime(10355): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
ERROR/AndroidRuntime(10355): at android.os.Handler.dispatchMessage(Handler.java:99)
ERROR/AndroidRuntime(10355): at android.os.Looper.loop(Looper.java:143)
ERROR/AndroidRuntime(10355): at android.app.ActivityThread.main(ActivityThread.java:4263)
ERROR/AndroidRuntime(10355): at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(10355): at java.lang.reflect.Method.invoke(Method.java:507)
ERROR/AndroidRuntime(10355): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
ERROR/AndroidRuntime(10355): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
ERROR/AndroidRuntime(10355): at dalvik.system.NativeStart.main(Native Method)
ERROR/AndroidRuntime(10355): Caused by: java.lang.IllegalArgumentException: Unable to load native library: /data/data/com.ggames.myApplication/lib/libmyApplication.so
ERROR/AndroidRuntime(10355): at android.app.NativeActivity.onCreate(NativeActivity.java:199)
ERROR/AndroidRuntime(10355): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
ERROR/AndroidRuntime(10355): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
ERROR/AndroidRuntime(10355): ... 11 more
WARN/ActivityManager(115): Force finishing activity com.ggames.myApplication/android.app.NativeActivity
WARN/dalvikvm(471): disableGcForExternalAlloc: false
WARN/dalvikvm(471): disableGcForExternalAlloc: false
WARN/ActivityManager(115): Activity pause timeout for HistoryRecord{40a7ac48 com.ggames.myApplication/android.app.NativeActivity}
DEBUG/SensorService(115): disable: connection.get() = 0x454e08
DEBUG/SensorService(115): disable: get sensor name = BMA150 3-axis Accelerometer
DEBUG/SensorService(115): SensorDevice::activate: handle = 0x0, enabled = 0x0
DEBUG/Sensors(115): Enable akm: en = 0
DEBUG/SensorService(115): noteStopSensor: uid = 0x3e8, handle = 0x0
DEBUG/SensorService(115): pid=115, uid=1000
DEBUG/SensorService(115): Active sensors:
DEBUG/SensorService(115): CM3602 Light sensor (handle=0x00000004, connections=1)
DEBUG/AK8973(79): Compass CLOSE
INFO/Process(10355): Sending signal. PID: 10355 SIG: 9
DEBUG/InputManagerService(115): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40910000
INFO/ActivityManager(115): Process com.ggames.myApplication (pid 10355) has died.
[/code:2ml7vv5x]

  • You must to post comments
0
0

> I put the fmodex.so file in "AndroidSDK\NDK\platforms\android-9\arch-arm\usr\lib" and used this makefile:
You shouldn’t need to do this.

> I have linked -lOpenSLES
You don’t need that either, unless you are doing your own OpenSLES code.

> LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lfmodex
I’d remove -lfmodex from here.

> LOCAL_SRC_FILES := FMOD/lib/android-9/armeabi/libfmodex.so
You probably want to change armeabi to $(TARGET_ARCH_ABI) so it will match armeab-v7a too.

If you are still having trouble I would recommend adding things from your setup to the recording example until you repro the crash.

  • You must to post comments
0
0

[quote:29wxwwi1]
> I put the fmodex.so file in "AndroidSDK\NDK\platforms\android-9\arch-arm\usr\lib" and used this makefile:
You shouldn’t need to do this.

> I have linked -lOpenSLES
You don’t need that either, unless you are doing your own OpenSLES code.

> LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lfmodex
I’d remove -lfmodex from here.
[/quote:29wxwwi1]

after reading and comiling the recording example, I realized this was the wrong approach and went with makefile #2, which is the same as the one in the example.

[quote:29wxwwi1]
> LOCAL_SRC_FILES := FMOD/lib/android-9/armeabi/libfmodex.so
You probably want to change armeabi to $(TARGET_ARCH_ABI) so it will match armeab-v7a too.
[/quote:29wxwwi1]

I am using a standard HTC Desire for development right now, which I am pretty sure is armeabi. In any case, I just tried the other configuration, and got the same issue.

I really don’t understand how the recording example could work, but not my own. the only difference that i can see is that the recording example uses a java activity instead of a native one.

edit: android seems to like to quit on you without any notice or error messages when you try to access a dangling pointer..is it possible that something fmod requires is missing in native non-java apps?

  • You must to post comments
0
0

Can you guys try to make an example project using the Android platform-9 native-activity example that comes with Android SDK? I just tried it myself, and it crashed, so it can’t be that there is anything wrong with my project.

  • You must to post comments
0
0

It would be good to have a native activity example for Android, I’ve added your request to our task tracker.

  • You must to post comments
Showing 15 results
Your Answer

Please first to submit.