Reputation: 465
I try add superpowered library to new android studio project and I follow example for Android but I still have problems with linking library.
I have this error:
java.lang.UnsatisfiedLinkError: No implementation found for void com.xxx.audiomixprototype.MainActivity.AudioMixPrototype(java.lang.String, long[]) (tried Java_com_xxx_audiomixprototype_MainActivity_AudioMixPrototype and Java_com_xxx_audiomixprototype_MainActivity_AudioMixPrototype__Ljava_lang_String_2_3J)
I follow short tutorial from Superpowered github readme https://github.com/superpoweredSDK/Low-Latency-Android-Audio-iOS-Audio-Engine
and everything is clear but I don't understand last point:
create your custom .cpp and .h files, then donÕt forget to properly set LOCAL_MODULE and LOCAL_SRC_FILES in Android.mk
Probably this is the reason why I can't link correctly this library. Any solutions how properly set LOCAL_MODULE and LOCAL_SRC_FILES?
Upvotes: 1
Views: 604
Reputation: 465
Ok I found the solution. When I copy SuperpoweredExample.cpp file I didn't change JNIEXPORT in this file.
I have this:
JNIEXPORT void Java_com_superpowered_crossexample_MainActivity_SuperpoweredExample(JNIEnv *javaEnvironment, jobject self, jstring apkPath, jlongArray offsetAndLength);
Instead this:
JNIEXPORT void Java_com_xxx_audiomixprototype_MainActivity_SuperpoweredExample(JNIEnv *javaEnvironment, jobject self, jstring apkPath, jlongArray offsetAndLength);
I know stupid mistake but maybe someone else will have the same problem.
Upvotes: 1
Reputation: 1705
I'm making some guesses here, so I'll outline my assumptions about your project.
1) You have a Java file with the line:
private native void AudioMixPrototype(String apkPath, long[] offsetAndLength);
2) You have a JNI implementation of this method in src/main/jni/filename.cpp
If you haven't set LOCAL_MODULE and LOCAL_SRC_FILES correctly in your Android.mk, Java won't be able to resolve the JNI call to this method, hence the link error. You'll need to add the following to your Android.mk:
include $(CLEAR_VARS)
# name your JNI module
LOCAL_MODULE := audio-mix-prototype
# assuming your Android.mk is also in src/main/jni,
# provide the filename to the JNI implementation of your method
LOCAL_SRC_FILES := filename.cpp
# add your flags, other libraries, etc. here
include $(BUILD_SHARED_LIBRARY)
There are some good examples in the Superpowered SDK. You can see an example of an Android.mk file for a project depending on Superpowered here.
Upvotes: 1