Problems creating an Android library with native code

I am trying to create an Android library project with native code. The Known Limitations section at http://tools.android.com/tech-docs/new-build-system/gradle-experimental supports hybrid library projects. But it seems that I do not see the native one, so the files are created in the libs folder of the aar library file.

This is how my project setup looks like

When I run this application, I get an UnsatisfiedLinkError, which I expected, since I do not see any native ones, therefore the files are generated in the aar file.

This is what the build.gradle file looks like in my library

apply plugin: 'com.android.model.library' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.1" } android.ndk { moduleName = "native" cppFlags = ['-std=c++11'] stl = "gnustl_shared" } } 

This is how my build.gradle application module looks like

 apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.1" } } dependencies { compile project(':mylibrary') } 
+5
source share
1 answer

This is a common problem in gradle 0.2.0 and 0.2.1 experiments. With the same problem, updated to 0.3.0-alpha4 , and it worked (just replace 0.2.0 with 0.3.0-alpha4 in your build.gradle project). To upgrade you will need gradle 2.6 (right-click on the module / open the module settings / select the Project / set gradle version 2.6 version submenu). Please note that I am using Android Studio 1.4 RC3.

+1
source

Source: https://habr.com/ru/post/1232333/


All Articles