问题描述
于是我从 https://github.com/libpd/pd得到了混帐回购协议-for-的Android ,并创造了Android的Studio中的一个新的空白项目,我的AmazingSynthesizer。
我用了导入模块向导导入PdCore和AndroidMidi。然后,右键点击应用来查看我的模块设置。在依赖我添加PdCore作为一个模块依赖。另外,我补充AndroidMidi作为一个模块依赖于PdCore。
到目前为止,似乎是正确的我。我的应用程序的build.gradle包括图书馆,我可以在我的MainActivity进口PdDispatcher。现在的问题是,它似乎仍然错过了本机库(我想!)。
从官方libpd书非常简单的例子code(由彼得·布林克曼制作音乐应用程序)
PdAudio.initAudio(采样率,0,2,8,真正的);
不幸地失败了。
java.lang.UnsatisfiedLinkError中:无法加载从装载机dalvik.system.PathClassLoader [DexPathList [zip文件PD "/data/app/com.app.amazingsynthesizer-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.app.amazingsynthesizer-1, /供应商/ lib中/系统/ lib目录]]]:findLibrary返回null
在java.lang.Runtime.loadLibrary(Runtime.java:358)
在java.lang.System.loadLibrary(System.java:526)
在org.puredata.core.PdBase< clinit>(PdBase.java:55)
在org.puredata.android.io.PdAudio.startAudio(PdAudio.java:86)
在com.app.amazingsynthesizer.MainActivity.onResume(MainActivity.java:62)
在android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192)
在android.app.Activity.performResume(Activity.java:5310)
在android.app.ActivityThread.performResumeActivity(ActivityThread.java:2764)
在android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2803)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2238)
在android.app.ActivityThread.access $ 800(ActivityThread.java:135)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1196)
在android.os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:136)
在android.app.ActivityThread.main(ActivityThread.java:5001)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:515)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:785)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
在dalvik.system.NativeStart.main(本机方法)
起床的最简单方法和运行是.so文件复制prebuilt为:
AmazingSynthesizer / src目录/主/ jniLibs
您需要libpd.so和libpdnativeopensl.so为您的目标体系结构,例如:
AmazingSynthesizer / src目录/主/ jniLibs / armeabi / libpd.soAmazingSynthesizer / src目录/主/ jniLibs / armeabi / libpdnativeopensl.so
So I've got the git repo from https://github.com/libpd/pd-for-android and created a new blank project in Android Studio for my "AmazingSynthesizer".
I used the "Import Module" wizard to import PdCore and AndroidMidi. Then, right clicked on "app" to view my "Module Settings". Under dependencies I've added PdCore as a module dependency. Also, I added AndroidMidi as a module dependency for "PdCore".
So far, that seemed right to my. My app's build.gradle includes the libraries and I can import PdDispatcher in my MainActivity. The problem is, that it still seems to miss the native libraries (I think!).
The very basic example code from the official libpd book (Making Musical Apps by Peter Brinkmann)
PdAudio.initAudio(sampleRate, 0, 2, 8, true);
fails miserably
java.lang.UnsatisfiedLinkError: Couldn't load pd from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.app.amazingsynthesizer-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.app.amazingsynthesizer-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at org.puredata.core.PdBase.<clinit>(PdBase.java:55)
at org.puredata.android.io.PdAudio.startAudio(PdAudio.java:86)
at com.app.amazingsynthesizer.MainActivity.onResume(MainActivity.java:62)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192)
at android.app.Activity.performResume(Activity.java:5310)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2764)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2803)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2238)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
The simplest way to get up and running is to copy the prebuilt .so files to:
AmazingSynthesizer/src/main/jniLibs
You'll need libpd.so and libpdnativeopensl.so for the architectures that you are targeting, for example:
AmazingSynthesizer/src/main/jniLibs/armeabi/libpd.soAmazingSynthesizer/src/main/jniLibs/armeabi/libpdnativeopensl.so
这篇关于在Android的Studio中使用libpd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!