0

I have an app that needs a .so library(ndk). It is compiled for armeabi-v7a. I compile the project with armeabi-v7a in Android Studio 1.5.1. When I run the project on a device(Android 4.4.2 and Android 6.0) it works just fine, the .so lib loads successfully.

The problem: I really need to test the app into an emulator so I've created an emulator for Android 6.0 with ARM(armeaabi-v7a) but unfortunately the .so is not loaded successfully and I get the following error: java.lang.UnsatisfiedLinkError.

03-30 14:52:12.654 16379-16379/com.mondelez.trylive I/tiInterface: Trying to load libtiAndroidAR2.so
03-30 14:52:12.867 16379-16379/com.mondelez.trylive E/tiInterface: WARNING: Could not load libtiAndroidAR2.so: java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.mondelez.trylive-2/lib/arm/libtiAndroidAR2.so: has text relocations
03-30 14:52:12.868 16379-16379/com.mondelez.trylive I/ti.dfusionmobile.tiInterface: Checking interface integrity
03-30 14:52:12.906 16379-16379/com.mondelez.trylive E/art: No implementation found for boolean ti.dfusionmobile.tiInterface.JNIglobalInitialize(int) (tried Java_ti_dfusionmobile_tiInterface_JNIglobalInitialize and Java_ti_dfusionmobile_tiInterface_JNIglobalInitialize__I)

I also followed these posts:

But didn't help.

It seems that the lib is incompatible but like I said: it is built with armeabi-v7a. Anyone have any suggestions or hints?

Here is my build.gradle:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:support-v4:23.2.0'
}

The .so file is located in: project/app/src/main/jniLibs/armeabi-v7a/myLib.so.

Community
  • 1
  • 1
Ispas Claudiu
  • 1,890
  • 2
  • 28
  • 54
  • Are you sure you tried the steps mentioned in http://stackoverflow.com/questions/32346402/libavcodec-so-has-text-relocations? Changing targetSdkVersion to 22 should let you work around this for now. The other answers in that post contain some background information on text relocations which will be helpful for solving the underlying problem in your code. – Francesca Nannizzi Mar 30 '16 at 17:24
  • @bullsy well I want to build the app for Android 6, and not 5. I will try the solution just to acknoledge it. – Ispas Claudiu Mar 31 '16 at 06:11
  • 2
    You cannot target API level 23 without fixing the text relocations (which you should plan to do). This is just the way to work around them until you get a chance to do that. However, targetSdkVersion does not affect how your app is compiled at all. To paraphrase this post: http://stackoverflow.com/questions/26694108/what-is-the-difference-between-compilesdkversion-and-targetsdkversion, it affects how the Android operating system treats your application. – Francesca Nannizzi Mar 31 '16 at 13:01
  • I want to use the request permission feature which is implemented starting from Android 6.0. I really want to know how to fix text relocations for a 6.0 application. This is the reason of my question. To compile the application with a lower version of Android it's not the solution for me. – Ispas Claudiu Mar 31 '16 at 13:11
  • You said you followed the posts linked above, but it isn't clear that you tried any of the steps. Did you try to locate the text relocations in your library? Where are they? What didn't work? – Francesca Nannizzi Mar 31 '16 at 18:16
  • I located the text relocations using: arm-l‌​inux-androideabi-readelf.exe -a libhcsample.so | grep TEXTREL if this is what your asking. I used ndkr8B also. I need to build it with this version of ndk. "What didn't work" this is what I'm looking/asking for. I posted on stackoverflow because here is the place where I can ask for help/guidance. I'm also trying to find the answer myself. So if you have any hints, answers, some "guidance lines" please post them as answers. If you think about some steps to follow please post them too. Thank you! – Ispas Claudiu Mar 31 '16 at 19:07
  • Maybe using targetSdkVersion 23 and NDK r8 doesn't work nice. Use the latest NDK. Also, you probably need two native lib flavours, with a separate one for API 23+. – Alex Cohn Apr 15 '16 at 16:12

0 Answers0