在 Android Studio 中使用 libpd [英] Using libpd in Android Studio

查看:34
本文介绍了在 Android Studio 中使用 libpd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我从 https://github.com/libpd/pd-for-android 并在 Android Studio 中为我的AmazingSynthesizer"创建了一个新的空白项目.

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".

我使用导入模块"向导导入 PdCore 和 AndroidMidi.然后,右键单击应用程序"以查看我的模块设置".在依赖项下,我添加了 PdCore 作为模块依赖项.另外,我添加了 AndroidMidi 作为PdCore"的模块依赖项.

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".

到目前为止,这对我来说似乎是正确的.我的应用程序的 build.gradle 包括库,我可以在我的 MainActivity 中导入 PdDispatcher.问题是,它似乎仍然缺少本地库(我认为!).

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!).

来自官方 libpd 书籍的非常基本的示例代码(Peter Brinkmann 编写的音乐应用程序)

The very basic example code from the official libpd book (Making Musical Apps by Peter Brinkmann)

PdAudio.initAudio(sampleRate, 0, 2, 8, true);

惨败

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)

推荐答案

[Updated 1/17/2016]

现在 pd-for-android 库工件已经发布到 jCenter,最简单的解决方案变得更简单:没有克隆,没有导入;只需编辑您项目的 build.gradle 文件并添加对 org.puredata.android:pd-core:1.0.0 的编译依赖项.

Now that the pd-for-android library artifact has been published to jCenter, the simplest solution got even simpler: no clones, no imports; just edit your project's build.gradle file and add a compile dependency on org.puredata.android:pd-core:1.0.0.

请参阅 pd-for-android 的更新自述文件以获取帮助.

See pd-for-android's updated README for help.

最初接受的答案:

启动和运行最简单的方法是复制预构建的 .so文件到:

The simplest way to get up and running is to copy the prebuilt .so files to:

AmazingSynthesizer/src/main/jniLibs

AmazingSynthesizer/src/main/jniLibs

架构需要 libpd.so 和 libpdnativeopensl.so您的目标,例如:

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

AmazingSynthesizer/src/main/jniLibs/armeabi/libpd.so AmazingSynthesizer/src/main/jniLibs/armeabi/libpdnativeopensl.so

这篇关于在 Android Studio 中使用 libpd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆