I'm new to Android, so forgive me if this seems a little amature. I have two pre-built static libraries, feta (../../feta/build/libfeta.a) and mish (../../mish/build/libmish.a), and I have the shared JNI library. Using the JNI library works perfectly fine, but I'm trying to access both feta and mish via the JNI library. These two libraries are constantly changed and updated along with the Android project so copying them every time they're built isn't really an option (if that'd even fix the linking problem), and I'd much not prefer simply copying the source files into the Android project.
I've tried searching, but most of the answers use the old version of the system and want me to modify Android.mk, which I don't have. I'm using the most recent version of Android Studio, it uses the Gradle plugin.
I've attempted to use all the configuration from over a dozen tutorials and Stackoverflow answers in various setups, but with no luck.
If you answer, please provide a full and working build.gradle so I don't run into the same problems I've been getting from the other answers (thanks!).
I've asked this question after just following this tutorial, so all the files will reflect that.
Here's the build error I'm getting:
Error:A problem occurred configuring project ':app'.
> The following model rules could not be applied due to unbound inputs and/or subjects:
android.sources { ... } # app/build.gradle line 58, column 5
subject:
- android.sources Object [*]
repositories { ... } # app/build.gradle line 39, column 5
subject:
- repositories Object [*]
[*] - indicates that a model item could not be found for the path or type.
Here's my build.gradle file inside the app module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.neonorb.mish_android"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-std=c++14 -Wno-implicit-exception-spec-mismatch"
}
}
ndk {
// ${targetPlatform.getName()}
// ${buildType.getName()}
stl "c++_static"
abiFilters "x86_64"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
model {
repositories {
libs(PrebuiltLibraries) {
feta {
headers.srcDir "../../feta/include/"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("../../feta/build/libfeta.a")
}
}
}
libs(PrebuiltLibraries) {
mish {
headers.srcDir "../../mish/include/"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("../../mish/build/libmish.a")
}
}
}
}
android.sources {
main {
jni {
dependencies {
library "feta" linkage "static"
library "mish" linkage "static"
}
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.android.support:design:25.1.0'
testCompile 'junit:junit:4.12'
}
And here's the root (mish-android) directory one:
// 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:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here's my CMakeLists.txt:
# Sets the minimum version of CMake required to build the native
# library. You should either keep the default value or only pass a
# value of 3.4.0 or lower.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds it for you.
# Gradle automatically packages shared libraries with your APK.
add_library( # Sets the name of the library.
mish-android
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
# Associated headers in the same location as their source
# file are automatically included.
src/main/cpp/mish.cpp )
# Searches for a specified prebuilt library and stores the path as a
# variable. Because system libraries are included in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in the
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( # Specifies the target library.
mish-android
# Links the target library to the log library
# included in the NDK.
${log-lib} )
Here's my directory structure if it helps at all.
As it turns out, I needed to upgrade my Gradle plugin. I was able to delete CMakeLists.txt. I also needed to upgrade my Gradle wrapper version to 3.2 to support the new experimental plugin.
Here's my root 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:2.2.3'
classpath 'com.android.tools.build:gradle-experimental:0.9.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here's my app build.gradle:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.neonorb.mish_android"
minSdkVersion.apiLevel 15
targetSdkVersion.apiLevel 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
ndk {
moduleName "mish-android"
ldLibs.add("log")
cppFlags.add("-std=c++14")
cppFlags.add("-Wno-implicit-exception-spec-mismatch")
// ${targetPlatform.getName()}
// ${buildType.getName()}
stl "c++_static"
abiFilters.addAll(["x86_64"])
// only build for x86_64 because that's all Feta and Mish support atm
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
}
}
sources {
main {
jni {
source {
srcDir "src"
}
dependencies {
library "feta" linkage "static"
library "mish" linkage "static"
}
}
}
}
}
repositories {
libs(PrebuiltLibraries) {
feta {
headers.srcDir "../../feta/include/"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("../../feta/build/libfeta.a")
}
}
}
libs(PrebuiltLibraries) {
mish {
headers.srcDir "../../mish/include/"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("../../mish/build/libmish.a")
}
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
}
Related
I am new to android development and I was developing an eye detecting video player app but I am getting this weird error in build i.e. when i am trying to run the app on my device:
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
My build.gradle(project) is
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My buid.gradle(app) is :
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.videoplayerai"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.github.Pradyuman7:LookAtMe:Version2.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
My settings.gradle :
import org.gradle.api.initialization.resolve.RepositoriesMode
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven { url = uri("https://dl.bintray.com/kotlin/kotlin-eap") }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://dl.bintray.com/kotlin/kotlin-eap") }
maven { url 'https://www.jitpack.io' }
gradlePluginPortal()
}
}
My gradle.properties is :
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
android.enableJetifier =true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
Plzz do help with my code and i have written the code in java ;)
I am using the android gradle experimental plugin to build an app module with some native code. This native code uses a library with pre-built .so files, which I am bundling into a .aar file via an android library module. The .aar file builds fine, but how do I link the native code module in the app module to the pre-built .so files in the .aar module? The gradle experimental documentation doesn't mention this scenario.
Also, I'd like to package up include files in the .aar file if possible (although they shouldn't be packaged with the final application).
In /prebuiltlib:
build.gradle
-src/
--main/
---jniLibs/
----libfoo.so
Here are the gradle files:
/prebuiltlib/build.gradle
apply plugin: "com.android.model.library"
model {
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion.apiLevel = 21
targetSdkVersion.apiLevel = 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
}
}
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:25.3.1"
}
Here is /app/build.gradle, note the ??? where I'm not sure what to put:
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.model.application'
model {
repositories {
libs(PrebuiltLibraries) {
// ??? is this right, and does this go into app/build.gradle or mylib/build.gradle?
foo {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file('???/libfoo.so')
}
}
}
}
android {
compileSdkVersion = 25
buildToolsVersion = '25.0.3'
defaultConfig {
applicationId = 'com.jeremy.stackoverflow.sample'
minSdkVersion.apiLevel = 21
targetSdkVersion.apiLevel = 21
versionCode = 1
versionName = '1.0'
}
ndk {
platformVersion = 21
moduleName = 'native-activity'
toolchain = 'gcc'
toolchainVersion = '4.9'
stl = 'gnustl_shared'
abiFilters.add('armeabi-v7a')
ldLibs.addAll(['log',
'android',
'EGL',
'GLESv2'
])
// ??? How do I add include paths from the .aar module?
cppFlags.add('-I' + file('???/include'))
cppFlags.addAll(['-std=c++11', '-fexceptions'])
}
sources {
main {
jni {
dependencies {
// ??? Is this right?
library 'foo' linkage 'shared'
}
}
jniLibs {
source {
// ??? Do I need one of these for the libs in the .aar?
srcDir file('???/jniLibs')
}
dependencies {
// ??? Is this right?
library 'foo'
}
}
}
}
buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.pro'))
}
}
}
}
dependencies {
println rootProject.getName()
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile project(':prebuiltlib')
}
Starting with Android Gradle Plugin 4.0, C/C++ dependencies can be imported from AARs linked in your build.gradle file. Gradle will automatically make these available to the native build system, but your build system must be configured to make use of the imported libraries and headers.
In gradle 4.0: add the following to your project's gradle.properties file:
android.enablePrefab=true
In gradle 4.1: add the following to the android block of your module's build.gradle file:
buildFeatures {
prefab true
}
, if your application defines libapp.so and it uses cURL, your CMakeLists.txt should include the following:
add_library(app SHARED app.cpp)
# Add these two lines.
find_package(curl REQUIRED CONFIG)
target_link_libraries(app curl::curl)
app.cpp is now able to #include "curl/curl.h", libapp.so will be automatically linked against libcurl.so when building, and libcurl.so will be included in the APK.
Source: https://developer.android.com/studio/build/native-dependencies
I've inherited a really messy android project with a lot of NDK dependencies and having a lot of problems with getting gradle to correctly link and include all .so and .a files into the resulting apk.
The project consists of some java code that sets up some activities and call into a big NDK library, built from C++ which in turn links with a dosens of 3rd party library (prebuilt or built from source).
I have managed to make it build with the latest gradle experimental plugin, but for some reason, my module isn't included in the apk while my 3rd party .so files are even though I can see that gradle have built my module into a .so file which it have placed in the build directory.
My build.gradle looks like this:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "22.0.1"
defaultConfig.with {
applicationId = "<removed>"
minSdkVersion.apiLevel = 7
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
ndk {
moduleName = "XM"
CFlags.add("-I${file("src/main/jni")}".toString())
cppFlags.addAll(["-I${file("../../3rd_part/android/osg")}".toString()])
cppFlags.addAll(["-I${file("../../3rd_part/android/opus")}".toString()])
ldFlags.add("-L${file("src/main/jniLibs/armeabi-v7a")}".toString())
ldLibs.addAll(["osgdb_jpeg", "osgdb_freetype", "jpeg","argsub_es", "jnigraphics", "android", "log"])
stl = "gnustl_shared"
abiFilters.add("armeabi-v7a")
}
sources {
main {
jni {
source {
srcDir "../../core"
srcDir "src/main/jni"
}
}
}
}
lintOptions.abortOnError = false
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.wunderlist:sliding-layer:1.1.1'
}
So to sum up my question: why does gradle build my module (libXM.so), place it into build/libs/xM/shared/armeabi-v7a/debug, but not include it into my final apk file?
I didn't get several things: if you want to build a shared library with gradle, then you have to use apply plugin: 'com.android.model.library' and not application
If you want to build an application and use prebuilt library, then you have to write something like this:
sources {
main {
jni {
source {
srcDir "../../core"
srcDir "src/main/jni"
}
dependencies{
library "XM" linkage "shared"
}
And, of course, to set ldFlags previously.
I am trying to integrate NDK into my project. I am using Gradle wrapper 2.9 and classpath:gradle-experimental:0.6.0-alpha3.
Project level gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha6'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App level gradle:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "com.ms.knowursensor.android"
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 23
}
}
compileOptions.with {
sourceCompatibility=JavaVersion.VERSION_1_7
targetCompatibility=JavaVersion.VERSION_1_7
}
android.ndk {
moduleName = "sensorgraph"
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.productFlavors {
create("arm") {
ndk.abiFilters += "armeabi"
}
create("arm7") {
ndk.abiFilters += "armeabi-v7a"
}
create("arm8") {
ndk.abiFilters += "arm64-v8a"
}
create("x86") {
ndk.abiFilters += "x86"
}
create("x86-64") {
ndk.abiFilters += "x86_64"
}
create("mips") {
ndk.abiFilters += "mips"
}
create("mips-64") {
ndk.abiFilters += "mips64"
}
create("all")
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
}
On building app, i receive this error:
Error:Unable to load class
'com.android.build.gradle.managed.BuildType$Impl'. Possible causes for
this unexpected error include:Gradle's dependency cache may be
corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires
network)The state of a Gradle build process (daemon) may
be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires
restart)Your project may be using a third-party plugin
which is not compatible with the other plugins in the project or the
version of Gradle requested by the project.In the case of
corrupt Gradle processes, you can also try closing the IDE and then
killing all Java processes.
After modifying description of proguard and product flavor i am receiving this error:
Error:A problem occurred configuring project ':app'.
> The following model rules could not be applied due to unbound inputs and/or subjects:
compileOptions.with { ... } # app\build.gradle line 15, column 5
subject:
- compileOptions.with Object [*]
dependencies { ... } # app\build.gradle line 68, column 6
subject:
- dependencies Object [*]
[*] - indicates that a model item could not be found for the path or type.
I had exactly the same problem, and the solution was putting 'dependencies' outside the model {}.
I don't know if this will solve your problem but it may have created complications that led up to it.
Try:
proguardFiles.add(file("proguard-rules.txt"))
ndk.abiFilters.add("armeabi")
Instead of the += operators. Support around the list aggregation methods has been chunky and I've found the .add() method is the one best supported.
Try killing the daemon and rerunning the build
gradle --stop && gradle clean build
I'm currently using Android Studio 2.0 preview 4. I have followed the guide from tools.android.com and tested NDK samples from github. The samples worked without a hitch, but when I implemented it on the SIPdroid project, it throws this error when I rebuild the project:
Error:(78, 1) A problem occurred configuring project ':app'.
Exception thrown while executing model rule: model.android
Cannot set readonly property: minSdkVersion for class: com.android.build.gradle.managed.ProductFlavor_Impl
when I try to use gradle project sync it gives this error:
Error:Unable to load class 'com.android.build.gradle.managed.ProductFlavor_Impl'.
Possible causes for this unexpected error include:You are using JDK version 'java version "1.7.0_79"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle.
Please update to a newer version (e.g. 1.7.0_67).
Open JDK SettingsGradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Android project structure now looks like this. previously the jni folder is separated from the java folder.
Here's my config:
SIPdroid/app/build.gradle
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "com.test.sipdroid"
minSdkVersion = 15
targetSdkVersion = 23
versionCode = 1
versionName = "1.0"
}
}
compileOptions.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
/*
* native build settings
*/
android.ndk {
moduleName = "SIPdroid"
/*
* Other ndk flags configurable here are
* cppFlags.add("-fno-rtti")
* cppFlags.add("-fno-exceptions")
* ldLibs.addAll(["android", "log"])
* stl = "system"
*/
}
android.sources {
main.java {
source {
srcDir 'src'
}
}
main.jni {
source {
srcDirs = []
}
}
main.jniLibs {
source {
srcDirs = ['src/main/libs']
}
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}
android.productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" #
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
SIPdroid/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.4.0'
// classpath 'com.android.tools.build:gradle:1.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
SIPdroid/gradle-wrapper.properties
#Mon Jan 04 16:06:26 PHT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
SIPdroid/local.properties
ndk.dir=/path/Android/sdk/ndk-bundle
sdk.dir=/path/Android/sdk
I just recently solved my issue by adding this to my orignal app/build.gradle file without using the experimental gradle build ('com.android.tools.build:gradle-experimental:0.4.0') as indicated in the google samples.
This solution finally solved the issue NDKBuild Failure. This additional script builds your jni files using ndkBuild.
app/build.gradle
sourceSets.main {
jniLibs.srcDir 'src/main/libs' // use the jni .so compiled from the manual ndk-build command
jni.srcDirs = [] //disable automatic ndk-build call
}
task ndkBuild(type: Exec) {
// commandLine 'ndk-build', '-C', file('src/main/jni').absolutePath <-- Not working
commandLine '/home/user/Android/sdk/ndk-bundle/ndk-build', '-C', file('src/main/jni').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
SIPdroid/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
You also need to have an empty libs folder under app/src/main. My mistake was that I renamed the /jni folder to /libs. After running the build, it will compile your jni to the /libs folder to .so files
jniLibs in your Android project structure view will look like this. This is from your app/src/main/libs as indicated in your build.gradle script
I hope this helps.