java.lang.UnsatisfiedLinkError: No implementation found (When Implement a SDK)

Issue

I am trying out to integrate a third-party SDK (DeepAR). But when I build it, that time it shows an error. I tried to fix it. If I create a simple new project it’s working properly. But my existing apps I use camera and ndk. Please help me to find out the error.

Here is the Cmakelist file.

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
        native-lib

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        src/main/cpp/native-lib.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
        native-lib

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})

Activity class

public class DeeparActivity extends AppCompatActivity implements AREventListener {

    private CameraGrabber cameraGrabber;
    private int defaultCameraDevice  Camera.CameraInfo.CAMERA_FACING_FRONT;
    private int cameraDevice  defaultCameraDevice;
    private DeepAR deepAR;
    private int currentMask  0;
    private int currentEffect  0;
    private int currentFilter  0;
    private int screenOrientation;
    ArrayList<String> masks;
    ArrayList<String> effects;
    ArrayList<String> filters;
    private int activeFilterType  0;
    private boolean recording  false;
    private boolean currentSwitchRecording  false;
    private String recordingPath  Environment.getExternalStorageDirectory() + File.separator + "video.mp4";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_deepar);

        deepAR  new DeepAR(this);
        deepAR.setLicenseKey("foobarbaz");
        deepAR.initialize(this, this);
        setupCamera();

    }
 private void setupCamera() {
    cameraGrabber  new CameraGrabber(cameraDevice);
    screenOrientation  getScreenOrientation();

    switch (screenOrientation) {
        case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
            cameraGrabber.setScreenOrientation(90);
            break;
        case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
            cameraGrabber.setScreenOrientation(270);
            break;
        default:
            cameraGrabber.setScreenOrientation(0);
            break;
    }

    // Available 1080p, 720p and 480p resolutions
    cameraGrabber.setResolutionPreset(CameraResolutionPreset.P1280x720);

    final Activity context  this;
    cameraGrabber.initCamera(new CameraGrabberListener() {
        @Override
        public void onCameraInitialized() {
            cameraGrabber.setFrameReceiver(deepAR);
            cameraGrabber.startPreview();
        }

        @Override
        public void onCameraError(String errorMsg) {
            AlertDialog.Builder builder  new AlertDialog.Builder(context);
            builder.setTitle("Camera error");
            builder.setMessage(errorMsg);
            builder.setCancelable(true);
            builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            });
            AlertDialog dialog  builder.create();
            dialog.show();
        }
    });
}
}

The exact error is given below

2020-11-20 00:17:37.274 7565-7728/com.songsterbd.songster E/IJKMEDIA: Option ijkiomanager not found.
2020-11-20 00:17:39.691 7565-7565/com.songsterbd.songster E/sterbd.songste: No implementation found for void ai.deepar.ar.DeepAR.setLicenseKeyN(java.lang.String) (tried Java_ai_deepar_ar_DeepAR_setLicenseKeyN and Java_ai_deepar_ar_DeepAR_setLicenseKeyN__Ljava_lang_String_2)
2020-11-20 00:17:39.692 7565-7565/com.songsterbd.songster E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.songsterbd.songster, PID: 7565
    java.lang.UnsatisfiedLinkError: No implementation found for void ai.deepar.ar.DeepAR.setLicenseKeyN(java.lang.String) (tried Java_ai_deepar_ar_DeepAR_setLicenseKeyN and Java_ai_deepar_ar_DeepAR_setLicenseKeyN__Ljava_lang_String_2)
        at ai.deepar.ar.DeepAR.setLicenseKeyN(Native Method)
        at ai.deepar.ar.DeepAR.setLicenseKey(DeepAR.java:223)
        at com.songsterbd.songster.view.activity.DeeparActivity.initializeDeepAR(DeeparActivity.java:363)
        at com.songsterbd.songster.view.activity.DeeparActivity.initialize(DeeparActivity.java:105)
        at com.songsterbd.songster.view.activity.DeeparActivity.onCreate(DeeparActivity.java:79)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)

I tried to fix it. Do let me know if any more information is needed. I am grateful to you. Thanks

Solution

After I week later I found the solution. It creates conflict with the library. I change CMakeLists file as a new then the conflict remove.

Now Working CMakeList file is:

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
        cpp-cla

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        src/main/cpp/cpp-cla.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
        cpp-cla

        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})

Answered By – Masum

Leave a Comment