16

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?

sebseb24
  • 310
  • 2
  • 11
  • I removed the image, sorry about that ! It's my first question, any advices on how to behave are appreciated ! – sebseb24 Nov 29 '17 at 18:38
  • You probably didn't understand: Instead of images of error messages or code post text instead please. – user0042 Nov 29 '17 at 18:41
  • This could be bad installation of NDK. Try to download NDK zip from the [official site](https://developer.android.com/ndk/downloads/index.html), unnpack it to `C:\Users\spomerleau\NDK`, and edit file **local.properties** in your project to look there. Another possible trouble could be that the path to your project is really long. Try to move `android-tutorial-5` to a location that is shorter (and has no spaces in path). – Alex Cohn Nov 29 '17 at 20:19

3 Answers3

7

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.

ystreet00
  • 240
  • 1
  • 4
  • Do you know how I could fix it ? I just tried updating my NDK to 16.1, but it didn't work. – sebseb24 Dec 14 '17 at 15:49
  • 1
    @sebseb24 You need to downgrade to NDK r15. See this answer (and specifically the link in the comment to the list of releases): https://stackoverflow.com/a/41989108/1172714 – dsh Jan 04 '18 at 21:47
  • I have the above issue can anyone help me with this? – Karunesh Palekar Aug 29 '20 at 17:19
3

This is due to Android Studio updating/installing to NDK_r16, which deprecated GCC support. Try reverting to NDK_r15c.

Download r15c from https://developer.android.com/ndk/downloads/older_releases.html, then point the app's NDK Location to the extracted folder.

  • I get that you can downgrade, but what about fixing your app/NDK installation so that you can use the current versions? – Questionmark Jun 01 '18 at 19:04
  • @Questionmark yes you are write but some time your system not support newer version. [Here](https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html) you can find requirement for v16 and map with your system . – Kartik Maheshwari Jun 02 '18 at 08:25
0

jni.h is a header file which is already present in the android ndk package. If it is not present you can either reinstall the package or you can search over the web for the source file which you can get very easily and place that file into the location your compiler is expecting it to be

Valgrind1691
  • 182
  • 1
  • 11