Hi Roman!

Thank you, apparently you were right!!

I have removed this code

tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask
->
    pkgTask.jniFolders = new HashSet<File>()
    pkgTask.jniFolders.add(new File(projectDir, 'native-libs'))
}

and added what you suggested.
The compiled code is now correctly added to the final APK and the
application runs!

I honestly think I couldn't have come up with a solution alone, and I don't
like this.

Where did you find the reference that you could use "applicationVariants"
in that way?

I tried to study gradle and the android plugin but I keep ending up
googling for a solution and including snippets of codes I can guess what
they do but I couldn't come up alone.
I would really appreciate if you can give me some direction on how to
become self sufficient on this :)


Really thank you Xavier D., Xavier H. and Roman! You all helped me a lot.

I hope the gradle plugin will eventually became compatible with my project
without me having to hack around it. I'll test all the next releases and,
if you are interested, I'll let you know!
Regards,
Daniele




On Mon, Jan 27, 2014 at 1:17 PM, Roman Mazur <[email protected]> wrote:

> I believe tweaking PackageApplication should work...
> Perhaps you call your
> "tasks.withType(com.android.build.gradle.tasks.PackageApplication)" before
> any task is really created.
>
> I would rather do it this way:
>
> android.applicationVariants.all { variant ->
>   variant.packageApplication.jniFolders = [new File(buildDir,
> 'native-libs')] as Set
> }
>
>
> On Thursday, 23 January 2014 18:14:37 UTC+2, Daniele Segato wrote:
>
>> Hi Xavier,
>>
>> I tried your suggestion.
>>
>> Project compile, assemble and get installed.
>> but the .so files are missing from the final apk file.
>>
>> 01-23 17:05:28.683  31464-31464/? E/JNIUtilsīš• The native library
>> libQCAR.so could not be loaded
>>
>>
>> I can see my compiled .so files in:
>>
>> build/native-libs/
>>
>> Does emptying srcDirs also skip the step of packaging native libs into
>> the APK or is something also changed in how the binary libraries are
>> included in the APK?
>>
>> I suspect this is ignored:
>>
>> tasks.withType(com.android.build.gradle.tasks.PackageApplication) {
>> pkgTask ->
>>     pkgTask.jniFolders = new HashSet<File>()
>>     pkgTask.jniFolders.add(new File(projectDir, 'native-libs'))
>> }
>>
>>
>> because of me adding this:
>> sourceSets.main.jni.srcDirs = []
>>
>> to the setting.
>>
>> Am I right?
>>
>> Currently for development I left android plugin 0.6 and gradle 1.8 in
>> files, Android Studio complains but let me do my stuff. I compile and
>> install from command line.
>>
>> Thanks and sorry for my late response.
>>
>> Regards,
>> Daniele
>>
>>
>>
>> On Tue, Jan 21, 2014 at 10:38 AM, Xavier Hallade <[email protected]>wrote:
>>
>>> Hi,
>>>
>>> In the current implementation the Android.mk is indeed ignored when the
>>> gradle NDK task is called.
>>> You can avoid the NDK task to be ran by setting this for example:
>>> sourceSets.main.jni.srcDirs = []
>>> and then you can call ndk-build on your project manually without any
>>> troubles.
>>>
>>>
>>> On Monday, January 20, 2014 10:56:06 AM UTC+1, Daniele Segato wrote:
>>>>
>>>> A correction:
>>>>
>>>> On Monday, January 20, 2014 10:53:56 AM UTC+1, Daniele Segato wrote:
>>>>>
>>>>> PROJECT_PATH is computed like this:
>>>>> PROJECT_PATH := $(abspath $(call my-dir)/../../../)
>>>>>
>>>>>
>>>>> The path is correct because it would complain about missing assimp.so
>>>>> otherwise.
>>>>>
>>>>
>>>> The path is correct if I execute ndk-build manually from the src/main
>>>> directory
>>>>
>>>>
>>>>
>>>  --
>>> 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/groups/opt_out.
>>>
>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.

Reply via email to