How to include C++ support through Android NDK in android studio?

172 views
Skip to first unread message

HMpzz

unread,
Dec 4, 2018, 11:08:03 AM12/4/18
to android-ndk
I am very new to android studio. The documentation I am reading is ndk guides. Here in the section 'Using the native_activity.h interface' there it says Create a jni/ directory in your project's root directory. This directory stores all of your native code. So I guess all native codes will be inside jni/. But when right click on the app/ directory there is no option to create a directory. I tried creating the folder through file manager but it doesn't show up in the project view.

I have ndk,cmake  installed as per documentation and When creating project I check include c++ support. There is a folder named cpp/ inside app/ which have a c++ file native-lib.cpp. Which I think is a sample code. So tried creating a c++ code there. But when I include native_activity header it can't find the header file. I included the new cpp file in cmake. As I said I am very new to studio and the ndk guide is very confusing . Am I missing some steps? Is creating jni/ directory is necessary or i can include my c++ code in app/cpp/? Why it can't find native_activity.h?  

Dan Albert

unread,
Dec 4, 2018, 1:26:25 PM12/4/18
to android-ndk, Adarsh Fernando
+adarshf: Looks like these docs could use some improvements.

On Tue, Dec 4, 2018, 08:08 HMpzz <unaba...@gmail.com wrote:
I am very new to android studio. The documentation I am reading is ndk guides. Here in the section 'Using the native_activity.h interface' there it says Create a jni/ directory in your project's root directory. This directory stores all of your native code. So I guess all native codes will be inside jni/. But when right click on the app/ directory there is no option to create a directory. I tried creating the folder through file manager but it doesn't show up in the project view.

I have ndk,cmake  installed as per documentation and When creating project I check include c++ support. There is a folder named cpp/ inside app/ which have a c++ file native-lib.cpp. Which I think is a sample code. So tried creating a c++ code there. But when I include native_activity header it can't find the header file. I included the new cpp file in cmake. As I said I am very new to studio and the ndk guide is very confusing . Am I missing some steps? Is creating jni/ directory is necessary or i can include my c++ code in app/cpp/? Why it can't find native_activity.h?  

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/5215444d-95f6-4776-bc14-314527151234%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Cohn

unread,
Dec 7, 2018, 9:36:27 AM12/7/18
to android-ndk
This would be <android/native_activity.h>. And jni folder is not relevant anymore

BR,
Alex
Reply all
Reply to author
Forward
0 new messages