2

I want to use JniLibs in my application. I have added a folder jniLibs under app/src/main. The folder jniLibs contains armeabi, armeabi-v7a, x86 and these folder contains .so files.

I have written the below code in build.gradle file:

sourceSets.main {
    jniLibs.srcDir 'libs'
    jni.srcDirs = [] //disable automatic ndk-build call
}

When I run my application is says : No implementation found for native.

I am new in implementing jniLibs in android studio, can you please help me. Thank you so much in advance for your help.

Prithniraj Nicyone
  • 5,021
  • 13
  • 52
  • 78
  • If you use `sourceSets`, your _libs_ folder must be at the **same** folder as your app's `build.gradle` – ecle Dec 01 '15 at 07:27
  • [How to include *.so library in Android Studio?](https://stackoverflow.com/a/28430334/6521116) – LF00 Jun 09 '17 at 02:29

2 Answers2

1

What is name of jni: "jni" or "jniLibs" ? you need add:

sourceSets.main {
    jni.srcDirs = []
    jniLibs.srcDir 'src/main/<name jni folder>'
}

If you have c file you need compile it:http://ph0b.com/new-android-studio-ndk-support/

mdtuyen
  • 4,470
  • 5
  • 28
  • 50
  • I have copied armeabi, armeabi-v7a, x86 folders in app/libs folder and created a new folder for jni libraries in app. Now I am getting only one issue which is : No implementation found for native method. I have explored it and did the same as suggested but the issue is still coming. Please help if you have any idea. – Prithniraj Nicyone Dec 01 '15 at 11:19
  • pls copy jni folder to under main folder and add as i showed to build.gradle (in android group) – mdtuyen Dec 01 '15 at 11:48
  • I have done the same but still not working :( Do I need to add anything else for jniLibs support? – Prithniraj Nicyone Dec 01 '15 at 12:24
  • I have copied my jni Library files from this library https://github.com/madhur/android-chat-starter, When I am running this code in android studio same code working here but not working in my app. The same error: No Implementation found for native method is coming. – Prithniraj Nicyone Dec 01 '15 at 12:32
  • the jni folder that you copy is c file so that you need setup to compile. What about .so file that you said ? – mdtuyen Dec 01 '15 at 12:35
  • if .so file in libs folder can't run. You must rebuild it from c code. – mdtuyen Dec 01 '15 at 12:38
  • read Using Android.mk/Application.mk item in my link to know how to setup. – mdtuyen Dec 01 '15 at 12:49
  • I have included the file image.c under jni folder in Android.mk file and the native function is defined in this file, but it is not working. Can you please help me. Thank you so much in advanced. – Prithniraj Nicyone Dec 01 '15 at 13:10
0

Remove the sourcesets lines. You dont need it. Because it is already defined as default.

Create a directory to your

Module (app for example) - > src -> main -> jniLibs

And you can put your .so files to in that folder.

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30