How to add prebuilt *.so library in android studio 2.2

时间:2016-10-20 18:42:43

标签: android android-ndk cmake

I tried to add library into project, but android studio ignore my lib. My CmakeLists.txt add_library( mylib SHARED IMPORTED ) set_target_properties(ffmpeg PROPERTIES IMPORTED_LOCATION src/main /libs/${ANDROID_ABI}/libmylib.so )

After building my apk not contain libmylib.so. How to add prebuilt library into project with cmake?

2 个答案:

答案 0 :(得分:7)

目前需要通过应用程序打包。它可能是这样的:

import scrapy
from faa_gov.items import FaaGovItem
class faa_gov(scrapy.Spider):
    name = "faa_actlnchlic"
    allowed_domains = ['faa.gov']
    start_urls = ['http://www.faa.gov/data_research/commercial_space_data/licenses/']

    def parse(self, response):
        licenses = response.xpath("//caption[text()='Active Launch Licenses']/following-sibling::tbody[1]/tr")
        for license in licenses:
            license_item = FaaGovItem()
            license_item['license'] = license.xpath('.//td[1]/a').extract()
            license_item['company'] = license.xpath('.//td[2]').extract()
            license_item['vehicle'] = license.xpath('.//td[3]').extract()
            license_item['location'] = license.xpath('.//td[4]').extract()
            license_item['expiration'] = license.xpath('.//td[5]/span').extract()
            yield license_item  

一个例子是:https://github.com/googlesamples/android-ndk/blob/master/hello-libs/app/build.gradle 如果你的共享库[你的是在项目路径内]靠近你的项目,那么将你的共享库的相对路径放到你的CMakeLists.txt就行了。

此错误底部的一些背景讨论可能会有所帮助: https://code.google.com/p/android/issues/detail?id=214664&can=8&q=vulkan&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened

答案 1 :(得分:2)

1 - In the root directory, create new folder: /libs in which and place your external libraries in there.

2 - Change the project structure

yourprojectname/
      app/
           - build.gradle  // Local Gradle configuration (for app only)
           ...
      libs/
           libraryName/
                - build.gradle // Local Gradle configuration (for library only)
      - build.gradle // Global Gradle configuration (for whole project)
      - settings.gradle
      - gradle.properties
      ...

3 - don't forget to change gradle.setting to

include ':app', ':libraryName'
project(':libraryName').projectDir = new File('libs/libraryName')

4-In app/build.gradle add your library

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile project(":PagerSlidingTabStrip")
}

Also there is way in android studio to add your library so it config gradle and project structure and it is :

1.File / Project Structure /

2.In module section find your project and in Dependancy tab add your library