简体   繁体   English

Android工作室;找不到jni.h.

[英]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. 我正在尝试使用他们网站上的教程在Windows上使用Android Studio构建GStreamer应用程序,但是,正如其他问题中已经提到的,这些教程不是最新的,也不适用于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. 我遵循了Eduardo Fernando提出的教程: Android Studio中的Gstreamer示例 ,但由于我无法解决未找到的jni.h文件问题,因此无法构建。

> 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. 我执行了javah命令,但生成的.h也找不到#include。

I tried the ndk-build command, but it will stop saying the jni.h file is missing. 我尝试了ndk-build命令,但它会停止说缺少jni.h文件。

Any advices on how I could link the jni.h file to the project? 有关如何将jni.h文件链接到项目的任何建议?

This is potentially a problem with the r16 changes in the Android NDK which are fixed upstream by the following commit 这可能是Android NDK中r16更改的问题,这些更改通过以下提交在上游修复

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. 问题是NDK将头文件移动到一个统一的结构中 ,从而打破了旧位置中任何用户期望的头文件。

This is due to Android Studio updating/installing to NDK_r16, which deprecated GCC support. 这是因为Android Studio更新/安装到NDK_r16,不赞成使用GCC支持。 Try reverting to NDK_r15c. 尝试恢复为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. https://developer.android.com/ndk/downloads/older_releases.html下载r15c,然后将应用程序的NDK位置指向解压缩的文件夹。

jni.h is a header file which is already present in the android ndk package. jni.h是一个头文件,已存在于android ndk包中。 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 如果它不存在,您可以重新安装软件包,也可以在Web上搜索可以轻松获取的源文件,并将该文件放入编译器期望的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM