As with Android Studio 1.3, it should be possible to automatically generate a JNI stub immediately after declaring the native method without using javah .
An example is here:
(from http://ph0b.com/new-android-studio-ndk-support/ )
I cant.
I use:
plugin: 'com.android.model.application' in the build.gradle application;classpath "com.android.tools.build:gradle-experimental:0.2.1" in the build.gradle project inside the dependancies ;distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip in gradle-wrapper.properties ;- In the project structure, I use
Gradle 2.5 , as required by the Gradle Experimental.
The scope of my NDK is as follows:
android.ndk { moduleName = "MyJNILibrary" cppFlags += "-std=c++11" stl = 'gnustl_shared' }
And finally, the class containing the JNI call:
package modules.jni;
public class JniClass { static { System.loadLibrary("MyJNILibrary"); } public static native String getStringFromJNI(); }
What is it. What am I doing wrong?
And I canโt even use javah because it wonโt find my class file in the src directory:
"C: \ Program Files \ Java \ jdk1.8.0_31 \ bin \ javah.exe" -d./jni -classpath C: \ Android-SDK \ platform \ android-23 \ android.jar; ... \ build \ intermediates \ Classes \ debug modules.jni.JniClass
Error: Could not find class file for 'JniClass'.
UPDATE 1:
My mistake, in my aforementioned command line, I use ...\ which is incorrect because it must be ..\ so I can use javah in the meantime.
source share