Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio ; jni.h not found

I'm trying to build a GStreamer app using Android Studio on windows using the tutorials on their website, but, as already mentioned in other questions, the tutorials are not up-to-date nor seems to work on Android Studio. I've followed the tutorial proposed by Eduardo Fernando at : Gstreamer examples in Android Studio, but it won't build since I can't manage to fix the issue of the jni.h file not found.

> Build command failed.
Error while executing process 
C:\Users\spomerleau\AppData\Local\Android\Sdk\ndk-bundle\ndk-build.cmd with 
arguments {NDK_PROJECT_PATH=null 

APP_BUILD_SCRIPT=C:\Users\spomerleau\Desktop\Android_GSTreamer\Premade_Test_tut5\android-tutorial-5\app\src\main\jni\Android.mk NDK_APPLICATION_MK=C:\Users\spomerleau\Desktop\Android_GSTreamer\Premade_Test_tut5\android-tutorial-5\app\src\main\jni\Application.mk APP_ABI=arm64-v8a NDK_ALL_ABIS=arm64-v8a NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=C:/Users/spomerleau/Desktop/Android_GSTreamer/Premade_Test_tut5/android-tutorial-5/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=C:\Users\spomerleau\Desktop\Android_GSTreamer\Premade_Test_tut5\android-tutorial-5\app\build\intermediates\ndkBuild\debug\lib C:/Users/spomerleau/Desktop/Android_GSTreamer/Premade_Test_tut5/android-tutorial-5/app/build/intermediates/ndkBuild/debug/obj/local/arm64-v8a/libtutorial-5.so}
  GStreamer      : [GEN] => gst-build-arm64-v8a/gstreamer_android.c
  GStreamer      : [COMPILE] => gst-build-arm64-v8a/gstreamer_android.c
  gst-build-arm64-v8a/gstreamer_android.c:1:10: fatal error: 'jni.h' file not found
  #include <jni.h>
           ^~~~~~~
  1 error generated.
  make: *** [gst-build-arm64-v8a/gstreamer_android.o] Error 1

I executed the javah command, but the generated .h cannot find the #include either.

I tried the ndk-build command, but it will stop saying the jni.h file is missing.

Any advices on how I could link the jni.h file to the project?

like image 505
sebseb24 Avatar asked Nov 29 '17 18:11

sebseb24


People also ask

Where is JNI H located?

The JNI header " jni. h " provided by JDK is available under the " <JAVA_HOME>\include " and " <JAVA_HOME>\include\win32 " (for Windows) or " <JAVA_HOME>\include\linux " (for Ubuntu) [Check Mac OS X] directories, where <JAVA_HOME> is your JDK installed directory (e.g., " c:\program files\java\jdk10. 0.

Where is JNI folder in Android Studio?

Right click on the "app" folder and select New->Folder->JNI Folder. This should create a folder under app/src/main called "jni". List your *. c files on LOCAL_SRC_FILES and the name your library on LOCAL_MODULE.

What is JNI in Android Studio?

JNI is the Java Native Interface. It defines a way for the bytecode that Android compiles from managed code (written in the Java or Kotlin programming languages) to interact with native code (written in C/C++).

What is NDK and JNI?

JNI is just the way that Java handles calling into native/C++ code, and calling back into Java from there. It has nothing to say about Android - it is a Java language feature. The Android NDK is a way to write Android applications using code called by JNI.


1 Answers

This is potentially a problem with the r16 changes in the Android NDK which are fixed upstream by the following commit

The problem is that the NDK moved the header files around into a unified structure and thus broke any user expecting headers in the old locations.

like image 180
ystreet00 Avatar answered Oct 18 '22 08:10

ystreet00