This is not yet supported by the plugin.

On Fri, Aug 7, 2015 at 9:33 AM, Ignas Brašiškis <[email protected]>
wrote:

> Same problem here, I am strugling to link third party so's.
>
> In Gradle 2.4 normal way to build against native so's was simple:
> In build sets add jniLibs in sourceset –
>
> sourceSets {
>         main {
>             jniLibs.srcDirs = ['jniLibs']
>         }
>     }
>
> As I understand sourceSets here are replaced by android.sources directive.
> I tried this:
>
> android.sources {
>     main {
>         java{
>             source{
>                 srcDir 'src'
>             }
>         }
>         jniLibs{
>             source{
>                 srcDir 'jniLibs'
>             }
>         }
>     }
> }
>
>
> Gradle runs well however it still does not link: in runtime I get link
> error. Any ideas how to solve it?
>
> 2015 m. rugpjūtis 7 d., penktadienis 19:00:38 UTC+3, Stéphane Saffré rašė:
>>
>> 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.
>



-- 
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. 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