1

Im trying to add .so files to my application and im getting the following error:

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)

i have tried to add

compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')

and

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)
}

the files are located under a directory named jniLibs -> armeabi-v7a/x86

enter image description here

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);

}

WalksAway
  • 2,769
  • 2
  • 20
  • 42
  • Possible duplicate of [No implementation found for int com.example.nimashahbazi.mooshak.EncryptingActivity.encrypt](https://stackoverflow.com/questions/45291082/no-implementation-found-for-int-com-example-nimashahbazi-mooshak-encryptingactiv) – qvotaxon Jan 19 '18 at 12:46
  • Put jniLibs directory in one of the following places and it will be picked up automatically. https://stackoverflow.com/a/35561184/2444099 No custom tasks necessary. – Eugen Pechanec Jan 19 '18 at 12:48
  • @EugenPechanec i already did put the jniLibs directory in app/src/main, but it did not pick it up – WalksAway Jan 19 '18 at 12:51
  • They *are* picked up automatically. If they weren't `System.loadLibrary` would throw exception. – Eugen Pechanec Jan 19 '18 at 13:40

0 Answers0