Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dlopen failed: library "libbinder.so" not found #4

Closed
Pillar1989 opened this issue Jul 4, 2018 · 4 comments
Closed

dlopen failed: library "libbinder.so" not found #4

Pillar1989 opened this issue Jul 4, 2018 · 4 comments

Comments

@Pillar1989
Copy link

We use native-libandroidthings in our project. but it print error "dlopen failed: library "libbinder.so" not found"

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.seeed.baozhu.mraa_demo"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -frtti -fexceptions"
            }
        }
        ndk {
            // Specifies the ABI configurations of your native
            // libraries Gradle should build and package with your APK.
            abiFilters 'armeabi-v7a'
        }

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs 'libs/mraa-1.8.0/jni'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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 files('libs/mraa-1.8.0/classes.jar')
}

06-20 01:35:45.560 29084-29084/com.seeed.baozhu.mraa D/AndroidRuntime: Shutting down VM
06-20 01:35:45.567 29084-29084/com.seeed.baozhu.mraa E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.seeed.baozhu.mraa, PID: 29084
java.lang.UnsatisfiedLinkError: dlopen failed: library "libbinder.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
at java.lang.System.loadLibrary(System.java:1657)
at com.seeed.baozhu.mraa.MainActivity.(MainActivity.java:18)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

@proppy
Copy link
Contributor

proppy commented Aug 7, 2018

Can you confirm that the same issue happen with the official sample: https://github.com/androidthings/sample-nativepio ?

@Pillar1989
Copy link
Author

@proppy Refer to googlearchive/tango-examples-c#117

libandroidthings link libbinder , but libbinder is non-NDK platform libraries.

https://github.com/aosp-mirror/platform_bionic/blob/master/android-changes-for-ndk-developers.md#private-api-enforced-for-api-level--24

I don't know if you've thought about it

@proppy
Copy link
Contributor

proppy commented Aug 8, 2018

@Pillar1989 are you trying to statically link libandroidthings?

It should be linked dynamically https://github.com/androidthings/sample-nativepio/blob/master/blink/src/main/cpp/CMakeLists.txt#L41, as when deployed your APK will use the one coming from the system image.

@Pillar1989
Copy link
Author

Yes,I copied this CMakeList.txt. I still wonder how native libandroidthings get around the non-ndk rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants