I am trying to implement hello-jni sample in my project. I have Gradle 2.8 and 'com.android.tools.build:gradle-experimental:0.4.0' and using Android Studio 2.0 Preview 3b .
This is my build.gradle :
apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.2" defaultConfig.with { applicationId = "lala.lala" minSdkVersion.apiLevel = 16 targetSdkVersion.apiLevel = 23 versionCode = 1 versionName = "1.0" } } /* * native build settings */ android.ndk { moduleName = "hello-jni" // cppFlags.add("-fno-rtti") // cppFlags.add("-fno-exceptions") // ldLibs.addAll(["android", "log"]) // stl = "system" } 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") } android.buildTypes { release { minifyEnabled = false //proguardFiles.add(file('proguard-rules.txt')) } } } 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' compile 'com.android.support:cardview-v7:23.1.1' compile 'com.android.support:recyclerview-v7:23.1.1' compile 'com.google.android.gms:play-services-ads:8.3.0' compile 'com.google.android.gms:play-services-analytics:8.3.0' compile 'com.google.android.gms:play-services-appindexing:8.3.0' }
I created in the JNI folder hello-jni.h :

In some part of my code, I import this:
static { System.loadLibrary("hello-jni"); } public static native int testMethod();
And when creating autocomplete hello-jni.c :
#include "hello-jni.h" JNIEXPORT jintJNICALL Java_lala_lala_HomeScreen_testMethod(JNIEnv *env, jclass type ) {
Header file hello-jni.h :
// // Created by Filip on 15.12.2015.. //
But that will not work. He is completely red:

What is the problem? How to solve it?
source share