I am trying to build an Android library project with native code. Per the "Known limitations" section under http://tools.android.com/tech-docs/new-build-system/gradle-experimental hybrid library projects are supported. But I don't seem to see the native so files being generated under the libs folder of the library aar file.
Here is how my project setup looks like
When I run this app I get an UnsatisfiedLinkError, which I expected as I see no native so files being generated in the aar file.
This is how my library build.gradle file looks like
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 app module's build.gradle looks like
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
}
}
dependencies {
compile project(':mylibrary')
}
This is a common problem in gradle experimental 0.2.0 and 0.2.1. Had the same problem, upgraded to 0.3.0-alpha4 and it worked (just replace 0.2.0
with 0.3.0-alpha4
in your project's build.gradle). To upgrade you will need Gradle 2.6 (right click on a module/Open Module Settings/ select the Project submenu/ set Gradle version field to 2.6). Note that I am using Android Studio 1.4 RC3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With