Originally posted on:http://www.kylethielk.com/blog/include-native-so-library-in-apk-with-android-studio/

Using the Android NDK is well documented throughout the internetifyou are still using Eclipse. The process is basically the same with Android Studio until the time comes to build your APK. The APK will build fine, but your library *.so file will be missing from the APK and when you attempt to load it with System.loadLibrary(“mylibrary”) you will get:

1
java.lang.UnsatisfiedLinkError: Couldn't load mylibrary from loader dalvik.system.PathClassLoader 

You can view the contents of your APK with the following command to verify libmylibrary.so is not in the APK:

1
unzip -l MyApp.apk

Android Studio’s build tool will not look in the usual place:

12 
SharedLibrary : libmylibrary.so Install : libmylibrary.so => libs/armeabi/libmylibrary.so 

The trick (thanks to this thread:https://groups.google.com/forum/#!msg/adt-dev/nQobKd2Gl_8/Z5yWAvCh4h4J) is to move libmylibrary.so to:

1
src/main/jniLibs/armeabi/libmylibrary.so

Voila, your native code is now compiled into your APK. This should work with build tools 0.8+

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android性能优化之布局优化
  2. android 中webview的屏幕适配问题
  3. android操作sdcard中的多媒体文件(一)——
  4. android 如何使用Wake Lock来节电?
  5. 多条未接来电只显示来电数,同时拨号应用通
  6. Android 开发工具介绍-SDK工具和平台工具
  7. Android(安卓)用户偏好设置,SharedPrefere
  8. 让View只显示下边框
  9. Android Jetpack系列之Lifecycle组件(一篇
  10. Android - ToolBar详解