Android and androidsdk
Add Standard C ++ files to JNI
Address: http://blog.csdn.net/caroline_wendy
Other references: http://blog.csdn.net/caroline_wendy/article/details/39032551
If you need to callStandard C ++ LibraryInJni folder, AddApplication. mkMethod.
InDeclare the standard template library (STL) using C ++):APP_STL: = gnustl_static
APP_STL := gnustl_staticAPP_CPPFLAGS := -frtti -fexceptions#APP_ABI := armeabi-v7a
Then create
Add C ++ source file and header file, In
Android. mk statement.
The header file is the folder path (the same directory can be omitted),The source file is the cpp file address.Note:"+ =", Indicating to continue adding
#LOCAL_C_INCLUDES += ./LOCAL_SRC_FILES += ./sayname.cpp
Android. mkSpecific file:
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE := HelloMyJniLOCAL_SRC_FILES := HelloMyJni.cpp#LOCAL_C_INCLUDES += ./LOCAL_SRC_FILES += ./sayname.cppinclude $(BUILD_SHARED_LIBRARY)
Header file and source file content:
/** Sayname. h ** Created on: September 4, 2014 * Author: Administrator */# ifndef SAYNAME_H _ # define SAYNAME_H _ # include <string> using namespace std; string sayname (void ); # endif/* SAYNAME_H _ * // ** sayname. cpp ** Created on: September 4, 2014 * Author: Administrator */# include "sayname. h "string sayname (void) {string str =" Hello Spike and Caroline and Wendy !!! "; Return str ;}
Interface files can be called, these standard C ++ files.
Specific call method:
#include <jni.h>#include "com_example_hellomyjni_JniClient.h"#include "sayname.h"JNIEXPORT jstring JNICALL Java_com_example_hellomyjni_JniClient_sayName (JNIEnv *env, jclass) {string str = sayname();return env->NewStringUTF(str.c_str());}
What is android
Android means a robot. android phones use android phones. Google developed android phones and android phones do not know what the android phones mean.
What is android
Android means a robot. android phones use android phones. Google developed android phones and android phones do not know what the android phones mean.