Android development, video group chat trigger SMS exception

Source: Internet
Author: User

When it comes to NDK development, there are some times when you need to call some of the bottom- C + + programs for your project needs, and in order to be more efficient.

But there are times when you don't have to, and that's why? Personal feeling sometimes feel trouble, first to configure the NDK to download Cygwin, configuration Cygwin, and then need to build, ah too troublesome. If you say the use of Eclipse, it is very simple to compile, but also need to configure a large number of early, ah, the configuration is wrong and can not afford to hurt.

Now Google's main push for Android Studio This is a good tool, at least now on the Eclipse can be done on this side, there is not necessarily eclipse on this side.

Let's talk about how to develop the NDK in Android Studio .

Getting ready to work Android Studio environment setup

In my previous article [Android] environment configuration, the official version of Android Studio 1.0 has been introduced.

NDK Environment Setup

Download: http://developer.android.com/tools/sdk/ndk/ Index.htmlwindows32:android-ndk-r10d-windows-x86.exewindows64:android-ndk-r10d-windows-x86_64.exemac OS X 32- Bit:android-ndk-r10d-darwin-x86.binmac OS X 64-bit:android-ndk-r10d-darwin-x86_64.binlinux 32-bit (x86) : Android-ndk-r10d-linux-x86.binlinux 64-bit (x86): Android-ndk-r10d-linux-x86_64.bin

are executable files, download and click to extract to the current folder, of course, you can use the command line for cross-folder decompression.

Establish a project Ndkdemo:

Establish the corresponding class, in Mathkit we implement the calculation of the square number of INT value.

1234567 publicclass MathKit {    public static native int square(int num);     static{        System.loadLibrary(JniDemo);    }}

Stringkit this is used by sucks:

123456 publicclass StringKit {    public static native void setNull(String str);    static{        System.loadLibrary(JniDemo);    }}

Prepare the. h file

Enter the Java directory; CMD enters the directory for Javah operations:

This presumably everyone is not unfamiliar with it, the file is the Java class corresponding to the header file, of course, if you are more powerful words can not be generated, your own knock code to complete the line;

as follows, create a folder:

Copy the previous file in:

Implemented separately:

Net_qiujuer_ndkdemo_jni_mathkit.cpp

12345678 #include <net_qiujuer_ndkdemo_jni_mathkit.h>JNIEXPORT jint JNICALL Java_net_qiujuer_ndkdemo_jni_MathKit_square  (JNIEnv *env, jclass cls, jint num)  {        returnnum*num;  }</net_qiujuer_ndkdemo_jni_mathkit.h>

Net_qiujuer_ndkdemo_jni_stringkit.cpp

12345678 #include <net_qiujuer_ndkdemo_jni_stringkit.h>JNIEXPORT void JNICALL Java_net_qiujuer_ndkdemo_jni_StringKit_setNull  (JNIEnv *env, jclass obj, jstring str)  {  }</net_qiujuer_ndkdemo_jni_stringkit.h>
Set up the project

Setting the root directory: local.properties

This setting is not required, and if you set the environment variable you can not set it, if not, then the settings will appear:


Set up an APP project Build.gradle

This setting is to set the generated JNI name to: Jnidemo.

Primary file invocation:

Now click on Run:

Can be seen is very simple, this call can be said to be the simplest I have done, and even generated. H files can be edited by the. sh file for batch processing (there is time to do this later).

A companion tour, a free dating site: www.jieberu.com

Push family, free tickets, scenic spots: www.tuituizu.com

Android development, video group chat trigger SMS exception

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.