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 internet if you 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. 1
  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. 1
  1. unzip -l MyApp.apk

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

  1. 1
  2. 2
  1. SharedLibrary : libmylibrary.so
  2. 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. 1
  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+

Include Native *.so Library in APK With Android Studio的更多相关文章

  1. Support Library官方教程(3)android studio中导入支援包

    Support Library Setup How you setup the Android Support Libraries in your development project depend ...

  2. 使用Android design support library在Eclipse和Android Studio

    背景:为了在低版本号下使用Android 5.0的一些新特新 Eclipse篇: 1.将Android Manager中的Android support library升级到最新,我的为22.2.1' ...

  3. APK在Android Studio下如何签名

    apk签名的意义 Android系统要求每一个Android应用程序必须要经过数字签名才能够安装到系统中,也就是说如果一个Android应用程序没有经过数字签名,是没有办法安装到系统中的! Andro ...

  4. 【转】如何使用Android Studio把自己的Android library分发到jCenter和Maven Central

    转自:http://www.devtf.cn/?p=760&utm_source=tuicool 如何使用Android Studio把自己的Android library分发到jCenter ...

  5. 如何通过Android Studio发布library到jCenter和Maven Central

    http://www.jianshu.com/p/3c63ae866e52# 在Android Studio里,如果你想引入任何library到自己的项目中,只需要很简单的在module的build. ...

  6. Android Studio将引用第三方jar包的library打包成jar包

    在该module的build.gradle中添加 task makeJar(type: Jar) { archiveName 'mysdk.jar' from('build/intermediates ...

  7. (转载) android studio library生成jar包和aar的方法总结

    android studio library生成jar包和aar的方法总结 标签: android学习文档jar和aar的使用与生成gradle 2016-11-25 10:39 1782人阅读 评论 ...

  8. Android Studio编译好的apk放在哪里?

    Eclipse中编译好的apk文件时在bin文件中面的,可是在Android Studio有一个比較大的修改了,编译好的apk在android studio里面是直接看不到了,并且apk文件所在文件夹 ...

  9. 【Android Studio安装部署系列】十、Android studio打包发布apk安装包

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 使用Android studio发布apk安装包的操作步骤. 开始打包发布apk Build > Generate Signe ...

随机推荐

  1. Python-memcached的基本使用

    想学Python,又想研究下memcached的客户端,于是拿Python-memcached研究研究~~~ 1.memcached的安装 请参考本博另一文章<Linux下安装memcached ...

  2. [转]ubuntu 10.04下的配置tftp服务器

    [转]ubuntu 10.04下的配置tftp服务器 http://www.cnblogs.com/geneil/archive/2011/11/24/2261653.html 第1步:安装tftp所 ...

  3. Content Template & DataTemplate 区别

    转一篇很好的博客: http://www.cnblogs.com/lzhp/p/3250786.html 介绍 listbox 的 Template.ItemsPanel.ItemContainerS ...

  4. 关于VS2010“ADO.NET Entity Data Model模板丢失或者添加失败问题

    我最近在安装vs2010后,添加ADO.NET Entity 实体时发现,我的新建项里面并没有这个实体模型,后来我就在博问里面发表了问题,请求大家帮忙解决,悲剧的是少有人回应啊,呵呵,不过我还是在网上 ...

  5. MATLAB GUI程序设计中ListBox控件在运行期间消失的原因及解决方法

    在运行期间,ListBox控件突然消失,同时给出如下错误提示: Warning: single-selection listbox control requires that Value be an ...

  6. 【BOZJ 1901】Zju2112 Dynamic Rankings

    Description 给定一个含有n个数的序列a[1],a[2],a[3]……a[n],程序必须回答这样的询问:对于给定的i,j,k,在a[i],a[i+1],a[i+2]……a[j]中第k小的数是 ...

  7. MyEclipse下直接查看class文件 jadnt158下载

    在没有源文件的情况下,通过倒入两个jar文件就可以实现 文件链接:http://pan.baidu.com/share/link?shareid=372924537&uk=2435113113 ...

  8. 【每日scrum】NO.4

    1.掌握了如何求两点间的最短距离这个算法.

  9. 学习Linux第六天

    1.Shell编程 bash变量: 都是以字符串格式存储 x=5 等号左右不能有空格,会当作命令处理 如何调用: echo $x 此法无法进行数值运算,不存在的变量输出空 set -u 设置变量报错 ...

  10. sqlserver 查看锁表,解锁

    查看被锁表: 代码如下 复制代码 select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName ...