Reference article http://ph0b.com/android-studio-gradle-and-ndk-integration/
After reading the above article for the Androidstudio integrated NDK generated so dynamic library has a very simple solution, the other things for the moment there is no hard things.
So we need to generate so files first, build them according to the ANDROID.MK and application.mk makefile configuration files in the Hello-jni sample project. Create a. c file with a. h file that is automatically generated from Javah and all files are in the JNI directory:
The contents of each file are as follows: Android.mk (simple generation of shared libraries only)
1 Local_path: = $ (call my-dir)23include $ (clear_vars)4 5 local_module : = com_examples_usejni_mainactivity6 local_src_files: = COM_EXAMPLES_USEJNI_MAINACTIVITY.C78 include $ (build_shared_library)
Application.mk (not too familiar with how ABI is used, so you can only generate so libraries on all platforms)
1 App_abi: = All
Com_examples_usejni_mainactivity.h
1 /*Do not EDIT this file-it are machine generated*/2#include <jni.h>3 /*Header for Class com_examples_usejni_mainactivity*/4 5 #ifndef _included_com_examples_usejni_mainactivity6 #define_included_com_examples_usejni_mainactivity7 #ifdef __cplusplus8 extern "C" {9 #endifTen #undefCom_examples_usejni_mainactivity_mode_private One #defineCom_examples_usejni_mainactivity_mode_private 0L A #undefCom_examples_usejni_mainactivity_mode_world_readable - #defineCom_examples_usejni_mainactivity_mode_world_readable 1L - #undefCom_examples_usejni_mainactivity_mode_world_writeable the #defineCom_examples_usejni_mainactivity_mode_world_writeable 2L - #undefCom_examples_usejni_mainactivity_mode_append - #defineCom_examples_usejni_mainactivity_mode_append 32768L - #undefCom_examples_usejni_mainactivity_mode_multi_process + #defineCom_examples_usejni_mainactivity_mode_multi_process 4L - #undefCom_examples_usejni_mainactivity_bind_auto_create + #defineCom_examples_usejni_mainactivity_bind_auto_create 1L A #undefCom_examples_usejni_mainactivity_bind_debug_unbind at #defineCom_examples_usejni_mainactivity_bind_debug_unbind 2L - #undefCom_examples_usejni_mainactivity_bind_not_foreground - #defineCom_examples_usejni_mainactivity_bind_not_foreground 4L - #undefCom_examples_usejni_mainactivity_bind_above_client - #defineCom_examples_usejni_mainactivity_bind_above_client 8L - #undefCom_examples_usejni_mainactivity_bind_allow_oom_management in #defineCom_examples_usejni_mainactivity_bind_allow_oom_management 16L - #undefCom_examples_usejni_mainactivity_bind_waive_priority to #defineCom_examples_usejni_mainactivity_bind_waive_priority 32L + #undefCom_examples_usejni_mainactivity_bind_important - #defineCom_examples_usejni_mainactivity_bind_important 64L the #undefCom_examples_usejni_mainactivity_bind_adjust_with_activity * #defineCom_examples_usejni_mainactivity_bind_adjust_with_activity 128L $ #undefCom_examples_usejni_mainactivity_context_include_codePanax Notoginseng #defineCom_examples_usejni_mainactivity_context_include_code 1L - #undefCom_examples_usejni_mainactivity_context_ignore_security the #defineCom_examples_usejni_mainactivity_context_ignore_security 2L + #undefcom_examples_usejni_mainactivity_context_restricted A #defineCom_examples_usejni_mainactivity_context_restricted 4L the #undefCom_examples_usejni_mainactivity_result_canceled + #defineCom_examples_usejni_mainactivity_result_canceled 0L - #undefCom_examples_usejni_mainactivity_result_ok $ #definecom_examples_usejni_mainactivity_result_ok-1l $ #undefCom_examples_usejni_mainactivity_result_first_user - #defineCom_examples_usejni_mainactivity_result_first_user 1L - #undefCom_examples_usejni_mainactivity_default_keys_disable the #defineCom_examples_usejni_mainactivity_default_keys_disable 0L - #undefCom_examples_usejni_mainactivity_default_keys_dialerWuyi #defineCom_examples_usejni_mainactivity_default_keys_dialer 1L the #undefCom_examples_usejni_mainactivity_default_keys_shortcut - #defineCom_examples_usejni_mainactivity_default_keys_shortcut 2L Wu #undefCom_examples_usejni_mainactivity_default_keys_search_local - #defineCom_examples_usejni_mainactivity_default_keys_search_local 3L About #undefCom_examples_usejni_mainactivity_default_keys_search_global $ #defineCom_examples_usejni_mainactivity_default_keys_search_global 4L - #undefCom_examples_usejni_mainactivity_honeycomb - #defineCom_examples_usejni_mainactivity_honeycomb 11L - #undefcom_examples_usejni_mainactivity_msg_really_stopped A #definecom_examples_usejni_mainactivity_msg_really_stopped 1L + #undefCom_examples_usejni_mainactivity_msg_resume_pending the #defineCom_examples_usejni_mainactivity_msg_resume_pending 2L - /* $ * class:com_examples_usejni_mainactivity the * Method:getstringfromnative the * Signature: () ljava/lang/string; the */ the jniexport jstring jnicall java_com_examples_usejni_mainactivity_getstringfromnative -(JNIENV *, jobject); in the #ifdef __cplusplus the } About #endif the #endif
Com_examples_usejni_mainactivity.c
1 " Com_examples_usejni_mainactivity.h " 2 jniexport jstring jnicall java_com_examples_usejni_mainactivity_getstringfromnative 3 (JNIENV *env, jobject thiz) {4 return (*env)->newstringutf (env,"Hello jnienv"); 5 }
Once these files have been written, just call the Ndk-build command in the normal way to generate all the so files.
In this way, all folders in the Libs are transferred to the Jnilibs directory:
This will allow you to use it correctly. Operation Result:
Above.
NDK Development Environment Configuration-androidstudio