我正在尝试在Android M开发预览版上测试我的应用程序。
我的应用程序使用的是共享库,我已将其放在Android Studio的jni / libs / armeabi中。我相信当它调用System.loadLibrary("myLib")
时会抛出以下UnsatisfiedLinkError。还有其他人有这个问题吗? Android 5.x对此没有任何问题。
06-02 08:24:28.004 16505-16505/com.me.workflow E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.me.workflow, PID: 16505
java.lang.UnsatisfiedLinkError: dlopen failed: library "{Path}/Android/Workflow/mobile/src/main//obj/local/armeabi/myLib.so" not found
at java.lang.Runtime.loadLibrary(Runtime.java:368)
at java.lang.System.loadLibrary(System.java:1076)
at com.me.workflow.service.WorkflowService.<clinit>(WorkflowService.java:108)
at com.me.workflow.activities.BaseServiceActivity.startWorkflowService(BaseServiceActivity.java:501)
at com.me.workflow.activities.WelcomeActivity.deployAndroidSetup(WelcomeActivity.java:639)
at com.me.workflow.activities.WelcomeActivity.onFileOperationCompleted(WelcomeActivity.java:842)
at com.me.workflow.tasks.CopyFromAssets.onPostExecute(CopyFromAssets.java:76)
at com.me.workflow.tasks.CopyFromAssets.onPostExecute(CopyFromAssets.java:42)
at android.os.AsyncTask.finish(AsyncTask.java:649)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:666)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5401)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:725)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:615)
更新
我收到了一些关于这个问题的反馈意见。在我的Android.mk文件中,我有下面这一行,目前认为这条路径不正确,并且由于它没有找到文件。
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/myLib.so
https://code.google.com/p/android-developer-preview/issues/detail?id=2239
答案 0 :(得分:4)
我解决了我的问题,确保我的预建库有一个soname设置。请参阅以下Android Developer Preview问题主题
https://code.google.com/p/android-developer-preview/issues/detail?id=2239
线程中的项目编号10谈到了我之前需要设置soname的预设,我之前没有。
所以在我的库构建脚本中,我将-Wl,-soname,lib {mylibname} .so添加到我的LDFLAGS变量
function remoteRequest ($url, $type='POST', $postValues=array(), $json=true, $parseResponse=true, $extraHeaders=array())
{
$curl = curl_init ($url);
$postValuesString = '';
if ($json && $postValues) {
$postValuesString = json_encode ($postValues);
}
curl_setopt ($curl, CURLOPT_TIMEOUT, 3);
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true);
if ($extraHeaders) {
curl_setopt ($curl, CURLOPT_HTTPHEADER, $extraHeaders);
}
if ($type == 'POST') {
curl_setopt ($curl, CURLOPT_POST, 1);
}
if ($postValues || $postValuesString) {
curl_setopt ($curl, CURLOPT_POSTFIELDS, $postValuesString ? $postValuesString : $postValues);
}
if ($json) {
if ($type == 'POST') {
curl_setopt ($curl, CURLOPT_CUSTOMREQUEST, "POST");
}
curl_setopt ($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Content-Length: ' . strlen($postValuesString)));
}
$rc = curl_exec ($curl);
curl_close ($curl);
return $rc;
}