English 中文(简体)
如何在APK内部预先建立共享图书馆
原标题:How to package prebuilt shared library inside an APK

This question seems to have been asked a lot but all were trying to use eclipse to package the library inside the APK. However, my requirement is to package the library inside the APK (which will later be loaded using System.loadLibrary() through Java) using the Android build system, i.e. i want to write an Android.mk file that does this job.

Requirement: 1. Prebuilt shared library: libTest.so 2. Write an Android.mk file that will package this to libs/armeabi-7 inside the apk.

我对我使用的建筑系统并不了解很多,但汇编是在出口所需环境变量之后使用“毫米”指挥进行的。

当我提供LOCAL-JNI_SHARED_LIBRARIES时,它试图在出口路线内发现它,而没有发现它,因此也就没有了。

任何人都可以向任何撰写安乐文的人提问。 将把我预先建造的共享图书馆纳入阿拉伯维持和平部队的小型档案?

最佳回答

为了掠夺贵国的本土图书馆,你必须

  1. Create jni folder in your project folder
  2. Create libs folder in your project folder
  3. Add Adnroid.mk make file to the jni folder, it should looks like this:

    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    
    LOCAL_LDLIBS    := -llog
    LOCAL_MODULE    := Test
    LOCAL_SRC_FILES := Test.cpp
    
    include $(BUILD_SHARED_LIBRARY)
    

注1:<代码> 试验是主要图书馆来源文件,载有本地方法的实施。 你可以增加更多来源,作为空间分离清单。

注2:不包括负责人,自动列入。

注3:如果您需要使C++ STL能够发挥作用,则创建另一个文档——>Application.mk,在jni的夹中添加该编号:

然后,你将不得不建立一个建筑商。 Refer to this article for how to do that:

在采取这些步骤之后,建筑商将在<条码>libs的夹中创建你的图书馆,在建立整个应用程序时将自动包装成纸浆。

注:您的图书馆名称应当降低,这是一份不光彩公约。 “校准”预设装置将自动增加,因此,最终的图书馆名称将进行校正。 因此。

问题回答

Let s say there is one libxxx.so shared library under libs/armeabi/ of project which you want to pack into apk. There are 2 things you need to do in the Android.mk as below:

# 1. Copy .so to out/target/product/***/obj/lib
$(shell cp $(wildcard $(LOCAL_PATH)/libs/armeabi/*.so $(TARGET_OUT_INTERMEDIATE_LIBRARIES)) 

# 2. Make libxxx to be packed into apk
LOCAL_JNI_SHARED_LIBRARIES := libs/libxxxx


Then you can use apktool to unpack the built apk, you will find the libxxx.so will be located in libs/armeabi*/. It is indeed packed into the apk.

我有两个联络处——JNI_SHARED_LIBRARIES,我想并入我的APK。 在我的安伯克,我可以这样做:

LOCAL_MODULE_TAGS := samples

在对单元进行重新校正之后,我得以根据校正/校准/校准在坡道找到两个图书馆。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签