我试图将.so文件添加到我的应用程序中并且我得到以下错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.getmagnet, PID: 22578
java.lang.UnsatisfiedLinkError: No implementation found for int com.getmagnet.App.MR.ActivateLibrary(java.lang.String) (tried Java_com_getmagnet_App_MR_ActivateLibrary and Java_com_getmagnet_App_MR_ActivateLibrary__Ljava_lang_String_2)
at com.getmagnet.App.MR.ActivateLibrary(Native Method)
at com.getmagnet.App.Application.onCreate(Application.java:9)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4566)
at android.app.ActivityThread.access$1500(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
我试图添加
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
和
task nativeLibsToJar(type: Jar, description: 'create a jar archive of the native libs') {
destinationDir file("$buildDir/native-libs")
baseName 'native-libs'
from fileTree(dir: 'libs', include: '**/*.so')
into 'lib/'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(nativeLibsToJar)
}
这些文件位于名为jniLibs的目录下 - > armeabi-V7A / 86
public class MR {
static {
System.loadLibrary("stlport_shared");
System.loadLibrary("fsdk");
System.loadLibrary("MirrorRealitySDK");
}
public static final int MAX_FACES = 5;
public static final int MASK_TEXTURE_SIZE = 1024;
public static final int SHIFT_TYPE_NO = 0;
public static final int SHIFT_TYPE_OUT = 1;
public static final int SHIFT_TYPE_IN = 2;
public static class TPointf {
public float x, y;
}
public static class MaskFeatures {
public TPointf features[] = new TPointf[FSDK.FSDK_FACIAL_FEATURE_COUNT];
}
public static int LoadMaskCoordsFromStream(InputStream stream, MaskFeatures maskCoords) {
Scanner scanner = new Scanner(stream);
if (!scanner.hasNextLine()) {
return FSDK.FSDKE_BAD_FILE_FORMAT;
}
String line = scanner.nextLine();
int count = Integer.parseInt(line);
if (count != FSDK.FSDK_FACIAL_FEATURE_COUNT) {
return FSDK.FSDKE_BAD_FILE_FORMAT;
}
for (int i=0; i<FSDK.FSDK_FACIAL_FEATURE_COUNT; ++i) {
maskCoords.features[i] = new TPointf();
}
for (int i=0; i<FSDK.FSDK_FACIAL_FEATURE_COUNT; ++i) {
if (!scanner.hasNextLine()) return FSDK.FSDKE_IO_ERROR;
line = scanner.nextLine();
String[] values = line.split(" ");
if (values.length != 2) return FSDK.FSDKE_BAD_FILE_FORMAT;
float x = (float) Double.parseDouble(values[0]);
float y = (float) Double.parseDouble(values[1]);
maskCoords.features[i].x = x;
maskCoords.features[i].y = y;
}
return 0;
}
public static native int LoadMaskCoordsFromFile(String filename, MaskFeatures maskCoords);
public static native int LoadMask(FSDK.HImage maskImage1, FSDK.HImage maskImage2, int maskTexture1, int maskTexture2, int [] isTexture1Created, int [] isTexture2Created);
public static native int DrawGLScene(int facesTexture, int facesDetected, FSDK.FSDK_Features[] /*must be [MAX_FACES]*/ features, int rotationAngle90Multiplier,int shiftType, int maskTexture1, int maskTexture2, MaskFeatures maskCoords, int isTexture1Created, int isTexture2Created, int width, int height);
public static native int ActivateLibrary(String licenseKey);
}