2016-01-25 188 views
1

我根據指令OpenCv with Android studio 1.3+ using new gradle - undefined reference執行了所有操作。但我有錯誤「無法加載庫」libgnustl_shared.so「」。誰知道我該如何解決這個問題?Android Studio NDK:無法加載庫「libgnustl_shared.so」

我的build.gradle文件:

應用插件: '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") 
      } 
+0

你可以發佈你的build.gradle嗎? – Andrew0x1

+0

當然可以。 –

回答

0

我下載了一組庫的libstdC++爲Linux,並把libgnustl_shared.so在jniLibs文件夾中。並在加載其他庫之前調用System.loadLibrary(「gnustl_shared」)。有用!

相關問題