Eventually, I managed to link to the libraries giving explicitely the path 
the the third-party library this way:

android.productFlavors {
    // for detailed abiFilter descriptions, refer to "Supported ABIs" @
    // https://developer.android.com/ndk/guides/abis.html#sa
    create("arm7") {
        ndk.abiFilters += "armeabi-v7a"
        ndk.ldFlags += "-Lsrc/main/jniLibs/armeabi-v7a"
    }
}


Is it the expected behaviour with the experimental 0.2.0 build plugin ?


Le vendredi 7 août 2015 18:00:38 UTC+2, Stéphane Saffré a écrit :
>
> Hello,
>
> I am struggling to build a simple native library depending on another 
> native third-party shared library (turbojpeg). This native library is 
> basically a wrapper of turbojpeg library.
>
> I have followed the documentation I have found here:
> http://tools.android.com/tech-docs/android-ndk-preview
> http://tools.android.com/tech-docs/new-build-system/gradle-experimental
>
> However I am unable to make Android Studio find the third-party library. 
> Here is the project setup
>
> Project build.gradle:
>
> // Top-level build file where you can add configuration options common to all 
> sub-projects/modules.
> buildscript {
>     repositories {
>        jcenter()
>     }
>     dependencies {
>         classpath 'com.android.tools.build:gradle-experimental:0.2.0'
>     }
> }
>
> allprojects {
>     repositories {
>         jcenter()
>     }
> }
>
>
>
> app module build.gradle:
>
> apply plugin: 'com.android.model.application'
> model {
>     android {
>         compileSdkVersion = 21
>         buildToolsVersion = "22.0.1"
>
>         defaultConfig.with {
>             applicationId = "com.stephane.turbojpegplugin"
>             minSdkVersion.apiLevel = 19
>             targetSdkVersion.apiLevel = 19
>         }
>     }
>     /*
>      * native build settings
>      */
>     android.ndk {
>         moduleName = "TurboJpegPlugin"
>         stl = "stlport_static"
>         ldLibs = [ "turbojpeg" ]
>         /*
>          * Other ndk flags configurable here are
>          * cppFlags += "-fno-rtti"
>          * cppFlags += "-fno-exceptions"
>          * ldLibs    = ["android", "log"]
>          * stl       = "system"
>          */
>     }
>     android.buildTypes {
>         release {
>             minifyEnabled = false
>             proguardFiles += file('proguard-rules.txt')
>         }
>     }
>     android.productFlavors {
>         // for detailed abiFilter descriptions, refer to "Supported ABIs" @
>         // https://developer.android.com/ndk/guides/abis.html#sa
>         create("arm7") {
>             ndk.abiFilters += "armeabi-v7a"
>         }
>     }
> }
>
>
> Gradle builds sucessfully with these files however at project build here 
> is the output:
>
> Information:Gradle tasks [clean, :app:compileArm7DebugSources, :app:
> compileArm7DebugAndroidTestSources]
> :app:clean
> :app:copyArmeabi-v7aDebugTurboJpegPluginSharedLibraryGdbServer
> :app:createArmeabi-v7aDebugTurboJpegPluginSharedLibraryGdbsetup
> :app:compileArmeabi-
> v7aDebugTurboJpegPluginSharedLibraryTurboJpegPluginMainCpp
> :app:linkArmeabi-v7aDebugTurboJpegPluginSharedLibrary
> D:\Dev\android-ndk-r10e\toolchains\arm-linux-androideabi-4.9\prebuilt\
> windows-x86_64\arm-linux-androideabi\bin\ld.exe
> Error:error: cannot find -lturbojpeg
> D:\Dev\projects\android\TurboJpegPlugin\app\src\main\jni\TurboJpegPlugin.
> cpp
> Error:(9) undefined reference to 'tjInitDecompress'
> Error:(10) undefined reference to 'tjDecompressHeader2'
> Error:(13) undefined reference to 'tjDecompress2'
> Error:(14) undefined reference to 'tjDestroy'
> Error:error: ld returned 1 exit status
> Error:Execution failed for task 
> ':app:linkArmeabi-v7aDebugTurboJpegPluginSharedLibrary'.
> > A build operation failed.
>      Linker failed while linking libTurboJpegPlugin.so.
>  See the complete log at: file:
> ///D:/Dev/projects/android/TurboJpegPlugin/app/build/tmp/linkArmeabi-v7aDebugTurboJpegPluginSharedLibrary/output.txt
> Information:BUILD FAILED
> Information:Total time: 0.763 secs
> Information:7 errors
> Information:0 warnings
> Information:See complete output in console
>
>
> The turbojpeg library is in the jniLibs folder like this:
>
>
> <https://lh3.googleusercontent.com/-yBTIB9DYN1E/VcTUDr-LKvI/AAAAAAAABb0/SVPc191qycM/s1600/2015-08-07_17h51_24.png>
>
> Following older articles/documentation, the jniLibs folder is where the 
> native shared libraries should be put to Android Studio automatically find 
> them but it seems it not the case anymore. Did I miss something?
>
> Any help would be greatly appreciated.
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to