apollox
apollox

Reputation: 111

Android 6 Marshmallow crash while calling native library

My app uses native library, and no problem from Android 2.2 to 5.1

But on Android 6 Marshmallow app crashes with error: E/AndroidRuntime(1602): java.lang.UnsatisfiedLinkError: No implementation found for int com.ipc.sdk.FSApi.Init() (tried Java_com_ipc_sdk_FSApi_Init and Java_com_ipc_sdk_FSApi_Init__) at com.ipc.sdk.FSApi.Init(Native Method)

How can I fix crash?

Update FSApi.java

   package com.ipc.sdk;
   public class FSApi 
   {
   ...  
   public static native int Init();
   ...
   static {
    try{
        System.loadLibrary("IOTCAPIs"); 
    }catch(UnsatisfiedLinkError ule)
    {
    }
    try{
        System.loadLibrary("RDTAPIs"); 
    }catch(UnsatisfiedLinkError ule){
    }
    try{
        System.loadLibrary("iconv");
        System.loadLibrary("FSApi"); 
    }catch(UnsatisfiedLinkError ule){
    }
   }
   }

In MainActivity I call:

FSApi.Init();

If I comment call:

// FSApi.Init();

no crash. It means that native libraries loaded succesfull. Also I get error in logcat:

No implementation found for int com.ipc.sdk.FSApi.Init() (tried Java_com_ipc_sdk_FSApi_Init and Java_com_ipc_sdk_FSApi_Init__) at com.ipc.sdk.FSApi.Init(Native Method)

It looks like Marshmallow tries to find Java_com_ipc_sdk_FSApi_Init or Java_com_ipc_sdk_FSApi_Init__ in the library, but without success. But if I open .so in the text editor, I'm finding Java_com_ipc_sdk_FSApi_Init !

Problem occurs only with two conditions together: 1. android:targetSdkVersion="23" in manifest 2. Device Android 6 Marshmallow.

On android:targetSdkVersion="22" and Android 6 Marshmallow not crashing, for android:targetSdkVersion="23" and devices before Marshmallow also not crashing.

Upvotes: 3

Views: 1713

Answers (1)

amouly
amouly

Reputation: 453

I had the same problem using the Foscam SDK for Android.

Like @135 said, you just need to change the targetSdkVersion to 21. Is not the best solution but it works with no crash.

I'm going to update this answer if I've found another workaround.

Upvotes: 3

Related Questions