R
R
RRTTRR2018-11-04 22:10:56
Java
RRTTRR, 2018-11-04 22:10:56

Why doesn't Android Studio see JNI functions?

Android Studio does not see JNI functions.
error:"Cannot resolve corresponding JNI function..."

build.gradle:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.m.f"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-frtti -fexceptions"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jni/jniLibs'] } }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation project(':openCVLibrary342dev')
}


face.java
... 
// C++:  Ptr_Facemark cv::face::createFacemarkAAM()
    private static native long createFacemarkAAM_0();

    // C++:  Ptr_Facemark cv::face::createFacemarkKazemi()
    private static native long createFacemarkKazemi_0();

    // C++:  Ptr_Facemark cv::face::createFacemarkLBF()
    private static native long createFacemarkLBF_0();
...

The function definition is in the *.so file.
The file is added to the jniLibs folder.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question