Configure android ndk for android studio code suggestion - android-studio

I'm new to android NDK and just know how to use native code in an java project as in this tutorial: http://kn-gloryo.github.io/Build_NDK_AndroidStudio_detail/
But when writing in C++ the IDE features for code completion, suggestion and other stuff disappear, while in java those features work as usual.
I tried to import some ndk sample from google, they are all written in C++ instead of calling native code from JNI as I'm doing, and the projects support code completion.
Can anyone show me a way to configure Android Studio for code completion to work when developing with NDK and JNI?

Related

use intellij kotlin kt file in android studio

I have written a program using intellij and want to import the code into android studio but i can't find any tutorials that have this specifically.
I am only able to find using kotlin in andoid studio or convert from kotlin to java.
I know it will be easy and that I am not looking in the right places but could really do with a pointer, I have been trying to do it all day lol im starting to loose the will!
Thanks
Not sure if I understood your question correctly, but if you have a bunch of code files and wanna import your code into Android Studio, the easiest way is to just create a new Android Studio Kotlin project, copy your code files from your IntelliJ project to your new Android Studio project, then adjust the code for Android.
If you do it inside the programs instead of in the file explorer, it will even adjust the package names for you.
Here's what I mean exactly by inside the programs:
If you want to create an Android application with the code that you write in IntelliJ. You can create an app in Android Studio and paste the code in the right place(should be in onCreate method) and manage the way that you will show the result. Also you can create an Android application in IntelliJ with the Android plugin.

Does Android Studio support Code completion for C/C++?

The code completion is fine on Android Studio java project. But I want to use Android Studio to edit some existing C file(.cpp).
for example, if i have declared some function, then i type the function in other section. But the android studio doesn't show up the code suggestion or some debugging.
Can Android Studio support Code completion for C/C++ like this:?
Yes it does, as long as the project is setup to use the NDK and the C/CPP sources are included in the project.
Try pulling the ndk sample repo and try opening one of the projects.
If you have a java project and want to edit some arbitrary C or C++ source, then no. It does not have enough information about the source file, include paths, compiler etc...
If your project uses Android.mk to build, it will be a bug of Android Studio. I have been reported.
Android.mk project cannot show code completion for cpp.
It seems that old version of Android Studio does not support code completion of jni native build (with Android.mk as configuration file), and that should already be fixed now.
But if you are using CMake in your project as external building tool and code completion still does not work, It's probably because you have more than one version of cmake installed. You can try to remove extra ones from SDK manager and restart Android Studio, it should work.
To see installed CMake version, you can open the SDK manager and check the 'show package details' on the right bottom. You can view cmake tools installed with different versions.

Android studio 1.4 Library module with JNI

I'm trying to create an android module with JNI in android studio, but all the documentation I found is for older versions of android studio that did not officially support JNI. So, what is the correct way to create Library module with JNI in Android studio 1.4?
It is exactly same as with 'com.android.model.application'. Everything seems to work fine except that for me, native debugging required running NDK build steps in the app module.

Add reference to CMake project in Android Studio

In my particular case, I implemented a cross platform project in C++11 that uses CMake. I initially designed this project to work on PC (Windows, Unix), but now I realized that I can use it on mobile platforms too, without re-implementing the business logic on every platform. The project uses standard libraries: Boost, Poco, OpenSSL, Protobuf.
After a few searches I came to conclusion that this is not even an usual mode to put together native and managed code in Android.
Is it possible to add reference in a Gradle project in Android Studio to a native project that uses CMake?
Can NDK adopt the project in a simple manner if I compile everything in command line (assuming I don't use Android Studio)?
If it is possible, is it recommended at all?
Is it possible to add reference in a Gradle project in Android Studio to a native project that uses CMake?
Since Google announced Android Studio 2.2 that comes with cmake plugin, so it's possible to reference CMake project to android project.
Can NDK adopt the project in a simple manner if I compile everything in command line (assuming I don't use Android Studio)?
In my experience, i compile NDK in separate way and then link the static/shared library (.so file) to be used in android project. I used NDK while developing PDF Reader using mupdf here
Hope this helps.
it would be possible with android studio 2.2, mainly the android plugin for gradle makes it possible. you could look at some examples in:
https://github.com/googlesamples/android-ndk/tree/master-cmake
android studio directly reads-in your cmake scripts -- there is nothing like desktop systems that generate project files for their native IDEs ( Visual Studio or XCode ); so you might have to modify your existing cmake files to eventually make it to work for android studio.
as long as you build to the correct APK, command line or IDE does not matter too much. If you intend to ship source code, having your project ready with an IDE would be attractive.
Please see CMaker_Boost, build the Boost with the CMake at a configure time. Now it is tested on the Linux and Android, gcc and clang. This can be included to the gradle project in the Android Studio. I hope this helps.

Android Studio JNI support

I would like to switch to Android Studio but it still do not support JNI projects. In my project Android.mk file is quite complex. I am doing many things in native code (FFMPEG and other c-implementations). Is it planned to extend Eclipse to Android Studio project converter to deal with converting of JNI part?? And more or less when it will be available??

Resources