# Setting up FMOD for Android – examples of Android.mk and project structures for NDK?

**URL:** https://qa.fmod.com/t/setting-up-fmod-for-android-examples-of-android-mk-and-project-structures-for-ndk/12490
**Category:** FMOD Studio
**Created:** [May 11, 2016, 12:39am UTC](https://qa.fmod.com/t/setting-up-fmod-for-android-examples-of-android-mk-and-project-structures-for-ndk/12490 "2016-05-11T00:39:38Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![arny](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@arny](https://qa.fmod.com/u/arny)
#### Post date: [May 11, 2016, 12:39am UTC](https://qa.fmod.com/t/setting-up-fmod-for-android-examples-of-android-mk-and-project-structures-for-ndk/12490/1 "2016-05-11T00:39:38Z")

</div>

I am trying to set up FMOD for Android, and have started with the examples provided in the API. I have not managed to set up a working project. However, I have downloaded a working project for Android Studio from here: [https://github.com/WillCoder/Fmod-Sample-3d](https://github.com/WillCoder/Fmod-Sample-3d)  
I can build and run this project. The example implemented is event\_parameter.cpp. As a start, I try to compile new .so files for another example using NDK, but I have not managed to get it working. I assume something is wrong with the Android.mk file or the project structure. I have searched for other questions on the topic, and in some answers there are references to examples of Android.mk in the API, but I haven’t found any examples in the lates API (1.08). I have modified the Android.mk from API 1.04:

LOCAL\_PATH := $(call my-dir)  
include $(CLEAR\_VARS)  
LOCAL\_MODULE := simple\_event  
LOCAL\_SRC\_FILES := simple\_event.cpp  
LOCAL\_C\_INCLUDES := $(LOCAL\_PATH)/inc  
include $(BUILD\_SHARED\_LIBRARY)

I get lots of “undefined reference to” errors in simple\_event.cpp, e.g. to Common\_Init(void\*\*), FMOD::Studio::System::create(FMOD::Studio::System\*\*, unsigned int), etc.  
Any ideas about what is wrong? Are there any example of project structures and Android.mk files?

---

<div class="post-metadata">

### Author: ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)
#### Post date: [May 12, 2016, 1:27am UTC](https://qa.fmod.com/t/setting-up-fmod-for-android-examples-of-android-mk-and-project-structures-for-ndk/12490/2 "2016-05-12T01:27:24Z")

</div>

It looks like you are missing the sections that define the FMOD libraries and the linker line to include them. Since we have switched our examples over the NVIDIA Nsight Tegra to allow Visual Studio usage I can see there is a gap in knowledge for working with the NDK toolchain. To help this I have added a section to our Android basic docs, here is a copy of what will be in our next release:

## Examples

For simplicity all FMOD examples make use of the [NVIDIA Nsight Tegra](http://developer.nvidia.com/nvidia-nsight-tegra) integration with Visual Studio.

To link FMOD into your native code using the NDK tool chain you can use the below Android.mk and Application.mk files as a guide.

This example assumes the two make files are placed in [FMOD SDK DIR]/api/studio/examples, that ndk-build is in your PATH environment variable and the current working directory is next to the make files.

```
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk NDK_APPLICATION_MK=Application.mk

```

**Android.mk**

```
LOCAL_PATH := $(call my-dir)

#
# FMOD Shared Library
# 
include $(CLEAR_VARS)

LOCAL_MODULE := fmod
LOCAL_SRC_FILES := ../../lowlevel/lib/$(TARGET_ARCH_ABI)/libfmodL.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../lowlevel/inc

include $(PREBUILT_SHARED_LIBRARY)

#
# FMOD Studio Shared Library
# 
include $(CLEAR_VARS)

LOCAL_MODULE := fmodstudio
LOCAL_SRC_FILES := ../../studio/lib/$(TARGET_ARCH_ABI)/libfmodstudioL.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../studio/inc

include $(PREBUILT_SHARED_LIBRARY)

#
# Example Library
#
include $(CLEAR_VARS)

LOCAL_MODULE := example
LOCAL_SRC_FILES := common_platform.cpp common.cpp simple_event.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SHARED_LIBRARIES := fmod fmodstudio

include $(BUILD_SHARED_LIBRARY)

```

**Application.mk**

```
APP_PLATFORM := android-4
APP_ABI := armeabi armeabi-v7a x86 arm64-v8a
APP_STL := stlport_shared
```

---

<div class="post-metadata">

### Author: ![arny](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@arny](https://qa.fmod.com/u/arny)
#### Post date: [May 16, 2016, 11:17am UTC](https://qa.fmod.com/t/setting-up-fmod-for-android-examples-of-android-mk-and-project-structures-for-ndk/12490/3 "2016-05-16T11:17:17Z")

</div>

> [@](#):
>
> It looks like you are missing the sections that define the FMOD libraries and the linker line to include them. Since we have switched our examples over the NVIDIA Nsight Tegra to allow Visual Studio usage I can see there is a gap in knowledge for working with the NDK toolchain. To help this I have added a section to our Android basic docs, here is a copy of what will be in our next release:
> 
> ## Examples
> 
> For simplicity all FMOD examples make use of the [NVIDIA Nsight Tegra](http://developer.nvidia.com/nvidia-nsight-tegra) integration with Visual Studio.
> 
> To link FMOD into your native code using the NDK tool chain you can use the below Android.mk and Application.mk files as a guide.
> 
> This example assumes the two make files are placed in [FMOD SDK DIR]/api/studio/examples, that ndk-build is in your PATH environment variable and the current working directory is next to the make files.
> 
> ```
> ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk NDK_APPLICATION_MK=Application.mk
> 
> ```
> 
> **Android.mk**
> 
> ```
> LOCAL_PATH := $(call my-dir)
> 
> #
> # FMOD Shared Library
> # 
> include $(CLEAR_VARS)
> 
> LOCAL_MODULE := fmod
> LOCAL_SRC_FILES := ../../lowlevel/lib/$(TARGET_ARCH_ABI)/libfmodL.so
> LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../lowlevel/inc
> 
> include $(PREBUILT_SHARED_LIBRARY)
> 
> #
> # FMOD Studio Shared Library
> # 
> include $(CLEAR_VARS)
> 
> LOCAL_MODULE := fmodstudio
> LOCAL_SRC_FILES := ../../studio/lib/$(TARGET_ARCH_ABI)/libfmodstudioL.so
> LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../studio/inc
> 
> include $(PREBUILT_SHARED_LIBRARY)
> 
> #
> # Example Library
> #
> include $(CLEAR_VARS)
> 
> LOCAL_MODULE := example
> LOCAL_SRC_FILES := common_platform.cpp common.cpp simple_event.cpp
> LOCAL_C_INCLUDES := $(LOCAL_PATH)
> LOCAL_SHARED_LIBRARIES := fmod fmodstudio
> 
> include $(BUILD_SHARED_LIBRARY)
> 
> ```
> 
> **Application.mk**
> 
> ```
> APP_PLATFORM := android-4
> APP_ABI := armeabi armeabi-v7a x86 arm64-v8a
> APP_STL := stlport_shared
> 
> ```

Thank you! This made it clear to me how to set up the FMOD API with NDK and Android Studio.

---

<div class="post-metadata">

### Author: ![talpa](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@talpa](https://qa.fmod.com/u/talpa)
#### Post date: [July 19, 2017, 7:51am UTC](https://qa.fmod.com/t/setting-up-fmod-for-android-examples-of-android-mk-and-project-structures-for-ndk/12490/4 "2017-07-19T07:51:58Z")

</div>

hi, i follow the guide from the docs and im getting NDK\_PROJECT\_PATH=Null in android studio  
i want to debug my c++ code directly from the studio.

and i dont understand this line:  
ndk-build NDK\_PROJECT\_PATH=. APP\_BUILD\_SCRIPT=Android.mk NDK\_APPLICATION\_MK=Application.mk  
where to put it ?

please help

---

<div class="post-metadata">

### Author: ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)
#### Post date: [July 21, 2017, 4:55am UTC](https://qa.fmod.com/t/setting-up-fmod-for-android-examples-of-android-mk-and-project-structures-for-ndk/12490/5 "2017-07-21T04:55:38Z")

</div>

This is an old post showing how to invoke ndk-build via the command line driven by an Application.mk and Android.mk. NDK\_PROJECT\_PATH=. (note the “.”) means the command line was invoked directly from the NDK project directory (the dir where Android.mk and Android.mk are).

---

<div class="post-metadata">

### Author: ![khanhjp1](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/khanhjp1/32/4743_2.png) [@khanhjp1](https://qa.fmod.com/u/khanhjp1)
#### Post date: [March 14, 2023, 2:39pm UTC](https://qa.fmod.com/t/setting-up-fmod-for-android-examples-of-android-mk-and-project-structures-for-ndk/12490/6 "2023-03-14T14:39:13Z")

</div>

please help me add fmod in android studio, can you video tutorial in project cocos2dx with Android Studio, Thank you very much!

---

<div class="post-metadata">

### Author: ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)
#### Post date: [March 16, 2023, 2:32am UTC](https://qa.fmod.com/t/setting-up-fmod-for-android-examples-of-android-mk-and-project-structures-for-ndk/12490/7 "2023-03-16T02:32:03Z")

</div>

Hi,

Unfortunately, we do not have a tutorial on adding FMOD to Android Studio at this time. Maybe you could elaborate on where you are getting stuck and I can try to assist further. I will point you toward our platform-specific guide in our documentation [FMOD API | Platform Details](https://fmod.com/docs/2.02/api/platforms-android.html).

Hope this helps!
