Include Native *.so Library in APK With Android Studio

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
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:

1
2
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+

时间: 2024-11-13 10:01:27

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

使用Android design support library在Eclipse和Android Studio

背景:为了在低版本号下使用Android 5.0的一些新特新 Eclipse篇: 1.将Android Manager中的Android support library升级到最新,我的为22.2.1' 2.在sdk->extras->android->m2repository->com->android->support->design->22.2.1->design-22.2.1.aar该文件解压,会有一个class.jar 导入到Android项目

如何使用Android Studio把library分享到jCenter和Maven Central

原文:How to distribute your own Android library through jCenter and Maven Central from Android Studio 如果你想在Android Studio中引入一个library到你的项目,你只需添加如下的一行代码到模块的build.gradle文件中. 1 2 3 dependencies { compile 'com.inthecheesefactory.thecheeselibrary:fb-like:0.

Android Studio把library分发到jCenter和Maven Central

如果你想在Android Studio中引入一个library到你的项目,你只需添加如下的一行代码到模块的build.gradle文件中. 1 2 3 dependencies { compile 'com.inthecheesefactory.thecheeselibrary:fb-like:0.9.3' } 就是如此简单的一行代码,你就可以使用这个library了. 酷呆了.不过你可能很好奇Android Studio是从哪里得到这个library的.这篇文章将详细讲解这是怎么回事,包括如何

如何使用Android Studio把自己的Android library分享到jCenter和Maven Central

如果你想在Android Studio中引入一个library到你的项目,你只需添加如下的一行代码到模块的build.gradle文件中. 1 2 3 dependencies {     compile 'com.inthecheesefactory.thecheeselibrary:fb-like:0.9.3' } 就是如此简单的一行代码,你就可以使用这个library了. 酷呆了.不过你可能很好奇Android Studio是从哪里得到这个library的.这篇文章将详细讲解这是怎么回事,

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

转自:http://www.devtf.cn/?p=760&utm_source=tuicool 如何使用Android Studio把自己的Android library分发到jCenter和Maven Central 原文链接 : How to distribute your own Android library through jCenter and Maven Central from Android Studio 译文出自 : 开发技术前线 www.devtf.cn与 泡在网上的日子

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

Eclipse中编译好的apk文件时在bin文件里面的,但是在Android Studio有一个比较大的改动了,编译好的apk在android studio里面是直接看不到了,而且apk文件所在目录也变了,那apk文件放在哪呢,你要在硬盘中找到对应的工程目录: E:\StudioDemo\MyApplication\app\build\outputs\apk 其中app是你的module,记得一定要在对应的module下找对应的编译好的apk文件. Android Studio编译好的apk放在

Co-Debugging JNI with Android Studio and Visual Studio

Tutorials > Android > Integration with other tools > Co-Debugging JNI with Android Studio and Visual Studio Co-Debugging JNI with Android Studio and Visual Studio December 20, 2014 android, android studio, ndk Warning! This tutorial uses outdated

Android Studio中Gradle使用详解

一)基本配置 build配置 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' } } Android脚本 apply plugin: 'com.android.application' Android配置 android { compileSdkVersion 22 buildToolsVersion "22.0.1" } 项

Android studio 使用心得(三)—从Eclipse迁移到Android studio

断断续续的也算是把eclipse上的代码成功迁移到android studio上来了,现在,我同事继续用eclipse,我用android studio,svn上还是之前eclipse的项目,迁移成功后,我也能happy的开发了,两不误.直接来分享我捉摸的一点小成果吧 以Demo4 为例,并引用了library包appcompat_v7_8. 1,第一步,Eclipse还是要有滴,并且adt 得在22以上,我相信大家adt肯定在22以上了吧,不然还开发个毛. (1) 在Eclipse中,选择Fl