我的客户提供了一个 .so 预构建的共享库。应该使用 libpd 加载,因为 libpd 控制器需要加载 m4aPlayer 模块。所以我把 libm4aPlayer.so 放在 app > main 下的 jniLibs(也试过 libs)文件夹中,然后我在 build.gradle 中添加了这个
defaultConfig {
ndk{
moduleName "m4aPlayer"
}
}
...
sourceSets {
main {
jni {
srcDirs = []
}
jniLibs {
srcDir 'libs'
}
}
}
然后在我的 AudioService 类(我在其中 initPd() 和 loadPatch())中,我试图调用客户端通过执行此操作提供的本机预建库
patchFile = new File(pdFile[0].mFile.getParent(), "pd/_main.pd");
//System.loadLibrary("pd");
System.loadLibrary("m4aPlayer");
PdBase.openPatch(patchFile);
PdBase.sendFloat("fadeTime", 12f);
每次我尝试打开补丁文件(_main.pd)时,我都会从 PD 控制器收到错误消息,提示“m4aPlayer 无法创建”。但我试图加载库仍然 pd 抛出这个错误。它确实可以很好地播放其他音频(其中 libpd 不需要 m4aPlayer 胶水。)
堆栈跟踪
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print: m4aPlayer
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print: error: ... couldn't create
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.840 6589-6589/com.test.test I/PdUiDispatcher: print: m4aPlayer
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: error: ... couldn't create
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: m4aPlayer
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: error: ... couldn't create
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: fadeTime: 12
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: fadeDelay: 3
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: curve: 30
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: musicVol: 1.5
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: voiceVol: 1.5
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: voiceGender: 1
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: isRandom: 1
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: suggestionsVO: 1
05-30 21:48:05.841 6589-6589/com.test.test I/PdUiDispatcher: print: availableSoundscapes:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 2
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 3
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 4
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 5
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 6
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 7
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 8
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.842 6589-6589/com.test.test I/PdUiDispatcher: print: 9
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print:
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print: module: 2
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print: INTO-Q: 0
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print: soundscape: 5
05-30 21:48:05.843 6589-6589/com.test.test I/PdUiDispatcher: print: toApp-isThisFileOK: p5intro0
我还尝试检查应用程序内部以确保是否正在复制库。所以我去了
data/data/package_name/lib