Issue
I am trying to use OpenAL on Android to generate spatial audio and I really struggled to wrap my mind around NDK and JNI and all that stuff.
Note: it's the first time i use JNI and NDK and i'm quite new to android development
But I found a library called OpenAL4Android. In addition here is an example app that's using it (under "HelloOpenAL4Android" title). The project is old and was done in Eclipse. So what I did was:
- imported the project in Android Studio (New->Import Project)
- created gradle.properties file and added android.useDeprecatedNdk=true; otherwise i get an error. Then Android Studio loaded "OpenAL4Android" as a library to the project(called "helloOpenAL4Android")
- changed the min and target sdk from 7 to 15(min) and 23(target) in build.gradle
- tried to build the project but i get the following error :
in openalwrapper.h header at
#include <AL/al.h>
#include <AL/alc.h>
and i also got this error when i was trying to build from Android Studio OpenAL4Android and OpenAL-MOB in order to integrate them in my projects.
On the other hand i managed to build the .so shared libraries for all ABI's not just armeabi from OpenAL4Android by runing :
ndk-build.cmd NDK_PROJECT_PATH=D:\AndroidProjects\OpenAL4Android\app\src\main
Do you know why i keep getting this error of AL/al.h not being found? I tried placing that folder(AL/al.h) everywhere, still not found.
Does it have to do with Android Studio not supporting NDK properly? Should i use an experimental gradle plugin?
It's really killing me.
...please help! :)
PS: sorry for the long post, i'm quite desperate i can't complete my project and i'm running out of time.
EDIT1:
This is my Android.mk file:
TARGET_PLATFORM := android-23
ROOT_PATH := $(call my-dir)
########################################################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := openal
#LOCAL_ARM_MODE := arm
LOCAL_PATH := $(ROOT_PATH)
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/../openal/include $(LOCAL_PATH)/../openal/OpenAL32/Include
LOCAL_SRC_FILES := ../openal/OpenAL32/alAuxEffectSlot.c \
../openal/OpenAL32/alBuffer.c \
../openal/OpenAL32/alDatabuffer.c \
../openal/OpenAL32/alEffect.c \
../openal/OpenAL32/alError.c \
../openal/OpenAL32/alExtension.c \
../openal/OpenAL32/alFilter.c \
../openal/OpenAL32/alListener.c \
../openal/OpenAL32/alSource.c \
../openal/OpenAL32/alState.c \
../openal/OpenAL32/alThunk.c \
../openal/Alc/ALc.c \
../openal/Alc/alcConfig.c \
../openal/Alc/alcEcho.c \
../openal/Alc/alcModulator.c \
../openal/Alc/alcReverb.c \
../openal/Alc/alcRing.c \
../openal/Alc/alcThread.c \
../openal/Alc/ALu.c \
../openal/Alc/android.c \
../openal/Alc/bs2b.c \
../openal/Alc/null.c \
LOCAL_CFLAGS := -DAL_BUILD_LIBRARY -DAL_ALEXT_PROTOTYPES
LOCAL_LDLIBS := -llog -Wl,-s
LOCAL_STATIC_LIBRARIES := libtremolo
include $(BUILD_SHARED_LIBRARY)
########################################################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := openalwrapper
LOCAL_ARM_MODE := arm
LOCAL_PATH := $(ROOT_PATH)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../openal/include $(LOCAL_PATH)/../openal/tremolo
LOCAL_SRC_FILES := openalwrapper.c \
org_pielot_openal_OpenAlBridge.c \
LOCAL_LDLIBS := -llog -Wl,-s
LOCAL_STATIC_LIBRARIES := libtremolo
LOCAL_SHARED_LIBRARIES := libopenal
include $(BUILD_SHARED_LIBRARY)
########################################################################################################
and the openal forder is at the same level with jni folder folder structure:
OpenAL4Android
-app
--src
---main
-----jni
-----openal
-----java
-----jniLibs
-----res
Solution
Nevermind, I got it working. I integrated it in my project. Had to use experimental gradle plugin and then had to run again ndk-build so it generated the libraries in libs folder. First I got some errors saying it can't find the implementation of the native methods because I thought it will get it's libraries from the jniLibs folder.
Answered By - Sami0806
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.