"不满意本土code滤波器QUOT;出口OSGi包含原生Android的lib时 [英] "Unsatisfied native code filter" when exporting OSGi bundle containing native Android lib
问题描述
我试图创建一个OSGi包使用本机C / C ++ code部署菲利克斯运行在Android设备上。
我是能够编译本地code和使用Android NDK臂Linux的工具链androideabi其链接到一个共享的对象。
现在,我尝试将OSGi包导出到使用eclipse PDE(导出 - >部署插件和片段).jar文件。此操作失败。错误窗口弹出告诉我:
导出插件遇到了问题。
列入处理从功能org.eclipse.pde.container.feature:捆绑my.bundle.jni_test_1.0.0.qualifier未能解决:
不满意本土code滤波器:当地人/ libjni_example.so;处理器=手臂; OSNAME = Linux操作系统。
当设置处理器以外的东西(如86),出口工作,但我在我的Android设备上启动时,它获得了一个捆绑未解决的约束的错误。
我希望,我没有做一些完全傻了。有没有人一个想法,到底是怎么回事错在这里?如何添加本地code编译Android的一个OSGi包?
有关完整性,附上了Java,C,清单和build.properties内容:
爪哇 - > JNI_Test:
包my.bundle.jni_test;
公共类JNI_Test {
私人无效的doWork(){
的System.out.println(3 + 3 =+添加(3,3));
}
静态的 {
的System.loadLibrary(jni_example);
}
公众最终静态本地加INT(INT X,int y)对;
}
Ç - > jni_example:
的#include包括/ my_bundle_jni_0005ftest_JNI_0005fTest.h
#包括LT&;&stdio.h中GT;
JNIEXPORT jint JNICALL Java_my_bundle_jni_1test_JNI_1Test_add(JNIEnv的* ENV,JCLASS clazz所jint X,jint Y){
焦炭BUF [100];
sprintf的(BUF,并称%d到%d \\ n,X,Y);
fprintf中(标准输出[INFO] - %S,BUF);
fflush(标准输出);
返回X + Y;
}
清单:
清单-版本:1.0
束ManifestVersion:2
束名称:JNI测试
束SymbolicName:my.bundle.jni_test
束版本:1.0.0.qualifier
束RequiredExecutionEnvironment:JavaSE的-1.6
捆绑本土code:当地人/ libjni_example.so; OSNAME = linux的;处理器=手臂
出口包装:my.bundle.jni_test
build.properties:
源.. = SRC /
输出.. =斌/
bin.includes = META-INF /,\\
,\\
当地人/ libjni_example.so
这似乎是下定义的目标平台'窗口 - > preferences - >插件开发 - 目标平台'prevented的出口成功的。
我添加了一个新条目复制从我目前的目标平台的设置(选择选项当前目标)。在那里,我'环境'的'建筑'价值'武装'下改变。作为ARM是不是下拉列表中提供一个选项,我手动键入它到文本字段。
就是这样。当使用该目标配置,现在一切工作正常。这个捆绑成功导出,我可以用它在我的Android设备上。
I try to create an OSGi bundle using native C/C++ code for deployment on an Android device running Felix.
I was able to compile the native code and link it to a shared object using the Android NDK arm-linux-androideabi toolchain.
Now, I try to export the OSGi bundle to a .jar file using eclipse PDE (Export->Deployable plug-ins and fragments). This fails. The error-window popping up tells me:
'Export Plug-ins' has encountered a problem.
Processing inclusion from feature org.eclipse.pde.container.feature: Bundle my.bundle.jni_test_1.0.0.qualifier failed to resolve:
Unsatisfied native code filter: natives/libjni_example.so; processor=arm; osname=linux.
When setting processor to something other (like x86), the export works but I get an "Unresolved constraint" error in the bundle when starting it on my Android device.
I hope, I'm not doing something completely silly. Has anyone an idea, what is going wrong here? How can I add native code compiled for Android to an OSGi bundle?
For completeness, I attach the Java, C, Manifest and build.properties content:
Java -> JNI_Test:
package my.bundle.jni_test;
public class JNI_Test {
private void doWork() {
System.out.println("3+3=" + add(3,3));
}
static {
System.loadLibrary("jni_example");
}
public final static native int add(int x, int y);
}
C -> jni_example:
#include "include/my_bundle_jni_0005ftest_JNI_0005fTest.h"
#include <stdio.h>
JNIEXPORT jint JNICALL Java_my_bundle_jni_1test_JNI_1Test_add(JNIEnv *env, jclass clazz, jint x, jint y) {
char buf[100];
sprintf(buf, "adding %d to %d\n", x, y);
fprintf(stdout, "[INFO] - %s", buf);
fflush(stdout);
return x+y;
}
Manifest:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JNI Test
Bundle-SymbolicName: my.bundle.jni_test
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-NativeCode: natives/libjni_example.so;osname=linux;processor=arm
Export-Package: my.bundle.jni_test
build.properties:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
natives/libjni_example.so
It seems like the target platform defined under 'Window -> Preferences -> Plug-in Development - Target Platform' prevented the export to succeed.
I added a new entry copying the settings from my current target platform (chose option 'Current Target'). There, I changed under 'Environment' the 'Architecture' value to 'arm'. As 'arm' was not an option provided by the drop-down list, I typed it manually into the text field.
That's it. When using this target configuration, everything works fine now. The bundle is exported successfully and I can use it on my Android device.
这篇关于&QUOT;不满意本土code滤波器QUOT;出口OSGi包含原生Android的lib时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!