I have compiled a C++ file, but do not meet the JNI format.
How can I use a .so library generated from a C++ file for different CPU architecture in Android?
You should use Android NDK. Do you need a link? It is integrated in Android Studio 2.3. Start with some sample apps to get used to this tool.
As Alex Cohn said to use C/C++ code in android you need Android NDK. You can download Android NDK directly from Android studio using the SDK Manager.
The steps needed to download NDK and use Cmake or ndkBuild to build native library of your c++ code.
1) In Android studio menu bar press on Tools->Android->Android->SDK Manager. And download cmake, LLDB and NDK.
2)If you downloaded the NDK and cmake when you create a new project tick the include button but this button is found in android studio 2.2 and above.
Related
Android Studio Tips
I have some ndk in SDK_ROOT/ndk dir, but Android studio can't recognize them.
I have to download a new one. Is there some difference between SDK_ROOT/ndk with SDK_ROOT/ndk-bundle
"ndk-bundle" is the one that's included with Android Studio, whereas "ndk" is the standalone one
ndk-bundle is referred to as the ndk shipped as part of Android Studio.
whereas in ndk you can have any number of ndk of different version.
Doing so helps you ensure reproducible builds across projects that each depend on a specific version of the NDK.
I am trying to install NDK in Android Studio 3.2.1 and I am following the procedure described here
It says I need to select LLDB, Cmake and NDK form the list in the SDK Manager,but I can only see LLDB and NDK in my computer, and CMake is absent
What do I need to do to install CMake and start coding using C? Or is installing just LLDB and NDK enough?
According to the docs on developer.android site:
Android Studio supports CMake, which is good for cross-platform projects, and ndk-build, which can be faster than CMake but only supports Android. Using both CMake and ndk-build in the same module is not currently supported.
You can only use one of the Cmake or NDK(as you see NDk is better but only developed for Android).
here is link of documentation for more info.
If you still have problem with installing cmake by sdk manager, make sure you are using 64 bit version of android studio.
for more information about how you can install Cmake or NDK you can see this answer
I am working on a school project which needs to customize AOSP. I have built an new API, also I have written apps that used these new API and they were compiled in my AOSP, they work just fine.
Now I have also compiled a SDK in my AOSP. I followed the instructions on this link to change the SDK path in android studio:
Android Studio - How to Change Android SDK Path
However, android studio still cannot resolve my new API. Does anyone have any idea on What I have done wrong? Or do I have some missing SDK tools that I need to install?
AOSP: android-5.0.2_r1
OS: Ubuntu 12.04
You will need to build the SDK from your custom version of AOSP. To do this you will need to build the 'sdk-eng' version using lunch and use the 'make sdk' build command. You can find detailed instructions inside the source code of AOSP. Here is a link specifically for the branch of AOSP you are building.
This will produce a custom framework.jar file which contains the Android API for your custom version. These files will just be stubs that do not contain actual code but do provide the API for developers to use. When building your application you will need to reference this framework.jar as your project SDK instead of one of the standard Google provided jars. This SDK jar should not be a compiled dependency as if will be provided by the custom version of Android you are running the application on.
Go to the folder in:
Android/Sdk/platforms/android-21/
Replace the android.jar with your custom made android.jar SDK and then inside Android Studio go to:
File --> Invalidate Cache & Restart
I used to download the Android NDK as new version were pubished to the devloper website.
It appears Google has recently updated the developer website and removed direct NDK download links, and replaced them with a a bunch of circular references that eventually lead to the SDK download. The SDK download page does not include the NDK. The closest I have found to a download and NDK is Download Android Studio and SDK Tools.
Running $ sudo /opt/android-sdk-macosx/tools/android does not offer a way to update the NDK.
How do I update the NDK in place using the existing NDK or one of the SDK tools?
Or where is the download of the actual NDK located?
To be clear, I use ant and ndk-build from the command line. I don't use Eclipse or Android Studio. Eclipse and the Android plugin is broken; and Android Studio does not really support NDK and JNI.
Plus, I don't really want to learn another editor since I kind of know Eclipse, and I know already how to do it from the command line (so there's no need for an editor).
In Android Studio, go to Tools (top-menu item) > Android > SDK Manager
Click SDK Tools tab
Scroll down and you will see NDK as an option, with detail if an update is available
I want to develop Android apps with Qt. I have Extracted the Android SDK and NDK to C:\. This is the NDK I downloaded:
https://squeak-android-vm.googlecode.com/files/android-ndk-1.6_r1-windows.zip
But Qt 5.2.1 does not detect the NDK and this error is shown:
"C:\android-ndk-1.6_r1" does not seem to be an Android NDK top folder.
Do I downloaded a wrong NDK? Did I miss something?
Thanks
First of all I strongly recommend to install the latest version of Qt for Android (5.4.1 at present). Also you should download and install Android SDK (ver. 22+) and NDK (ver. r9+) from here.
After downloading extract them. For Android SDK you should have a connection to Internet and download the desired tools. you have to install at least Android API-13! You should also install Android SDK Platform-tools and Android SDK Build-tools.
I had the same problem. The problem was I first created a Android NDK folder to extract the Android NDK files into it. The extraction procession then created a sub folder of the same name. To solve the problem, I moved the sub folder one directory level up and deleted the initial Android NDK folder I first created.