Android Studio NDK: could not load library "libgnustl_shared.so"

I did everything according to the instruction OpenCv with Android studio 1.3+ using new gradle - undefined reference. But I have error "could not load library "libgnustl_shared.so"". Who knows how can I solve this problem?

My build.gradle file:

apply plugin: 'com.android.model.application'

            model {
                android {
                    compileSdkVersion = 23
                    buildToolsVersion = "23.0.2"

                    defaultConfig.with {
                        applicationId = "com.atapy.wisetrend3"
                        minSdkVersion.apiLevel = 11
                        targetSdkVersion.apiLevel = 23
                        versionCode = 1
                        versionName = "1.0"

                    }
                }

                android.ndk {
                    moduleName = "rrdecoder"
                    cppFlags.add("-std=c++11")
                    cppFlags.add("-fexceptions")
                    cppFlags.add("-I${file("D:/Android/OpenCV-3.1.0-android-sdk/OpenCV-android-sdk/sdk/native/jni/include")}".toString())
                    ldLibs.addAll(["android", "EGL", "GLESv2", "dl", "log", "z"])
                    stl = "gnustl_shared"
                }

                android.buildTypes {
                    release {
                        minifyEnabled = false
                        proguardFiles.add(file("proguard-rules.txt"))
                    }
                }

                android.productFlavors {
                    create("arm") {
                        ndk.with{
                            abiFilters.add("armeabi")

                            File curDir = file('./')
                            curDir = file(curDir.absolutePath)
                            String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\armeabi\\"

                            ldLibs.add(libsDir + "libopencv_core.a")
                            ldLibs.add(libsDir + "libopencv_highgui.a")
                            ldLibs.add(libsDir + "libopencv_imgproc.a")
                            ldLibs.add(libsDir + "libopencv_java3.so")
                            ldLibs.add(libsDir + "libopencv_ml.a")

                        }
                    }
                    create("armv7") {
                        ndk.with {
                            abiFilters.add("armeabi-v7a")

                            File curDir = file('./')
                            curDir = file(curDir.absolutePath)
                            String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\armeabi-v7a\\"
                            ldLibs.add(libsDir + "libopencv_core.a")
                            ldLibs.add(libsDir + "libopencv_highgui.a")
                            ldLibs.add(libsDir + "libopencv_imgproc.a")
                            ldLibs.add(libsDir + "libopencv_java3.so")
                            ldLibs.add(libsDir + "libopencv_ml.a")
                            ldLibs.add(libsDir + "libopencv_ts.a")

                        }
                    }
                }
                android.sources {
                    main {
                        jni {
                            source {
                                srcDirs += ['src/main/jniMy']
                            }
                        }
                    }
                }
            }
            dependencies {
                compile fileTree(dir: "libs", include: [$/*.jar/$])
                compile "com.android.support:appcompat-v7:23.1.1"
                compile project(":openCVLibrary310")
            }

Answers


If you don't mind moving up in version with gradle experimental, I posted an example of my build script that links in opencv and uses gnustl_shared here: Migrating project to new experimental gradle plugin 0.6.0-alpha3 -> 0.6.0-alpha5


I downloaded a set of libraries libstdc++ for Linux and put libgnustl_shared.so in the jniLibs folder. And called System.loadLibrary("gnustl_shared") before loading other libraries. It works!


Need Your Help

Django POST listener in Elastic Beanstalk to receive AWS Worker Tier requests

python django amazon-web-services amazon-ec2 worker

I'm trying to set up a Worker Environment to run a background task. I have the same application version running on two Environments, one is the web server and the other one is the Worker.

Create profile image upload feature

html image mobile file-upload

I'm trying to add a profile image upload feature to my mobile app but i can't figure how to do it. Can anyone provide a solution?