Android的NDK:如何包括AndroidStudio * .so文件 [英] Android NDK: how include *.so files in AndroidStudio

查看:248
本文介绍了Android的NDK:如何包括AndroidStudio * .so文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我林达罐和*。所以。我创建Eclipse项目作为教程(此库)。我现在做的项目Android Studio中,但系统无法找到* .so文件。我做如何在此 - <一个href=\"http://stackoverflow.com/questions/16683775/include-so-library-in-apk-in-android-studio\">Include在APK .so库在Android Studio中。我的应用程序不会在这么库发现的功能。如何找到他们呢?
日志:

I have libs jar and *.so. I created Eclipse project as in tutorial (for this libs). I am now doing project in Android Studio, but system can't find *.so files. I make how in this - Include .so library in apk in android studio . My app does not find function in so libs. How to find them? Log:

10-16 12:16:55.965: W/dalvikvm(4386): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/atol/drivers/fptr/IFptrNative;
10-16 12:16:55.965: W/dalvikvm(4386): threadid=1: thread exiting with uncaught exception (group=0x41869438)
10-16 12:16:55.976: E/AndroidRuntime(4386): FATAL EXCEPTION: main
10-16 12:16:55.976: E/AndroidRuntime(4386): java.lang.ExceptionInInitializerError

使用JAR库创建对象时发生错误。她又戳* .so文件,但要找到她需要什么。是谁的责任,做些什么?

An error occurs when creating an object using a JAR library. She in turn poked *.so files, but to find what she needs. Who is to blame and what to do?

推荐答案

三个选项:

复制你的* .SO在文件夹库和把那的build.gradle

Copy yours *.SO libraries on your libs folder and put that on Build.gradle:

dependencies
        {
    compile fileTree(include: ['*.jar'], dir: 'libs')
}

两个

请在的src / main / jniLibs 一个新文件夹,并写上你的的build.gradle

Make a new folder on src/main/jniLibs and write that on your Build.gradle:

android {

//.................Another code 

 sourceSets
  {
      main
       {

           jniLibs.srcDirs = ['src/main/jnilibs']

       }

//Another code 

}//Android tag close

请在的src / main / jniLibs 一个新文件夹,并写上你的的build.gradle

Make a new folder on src/main/jniLibs and write that on your Build.gradle:

//Another code....

    dependencies
    {
          compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
    }//end dependencies


    task nativeLibsToJar(type: Jar, description: 'create a jar archive of the native libs') {
        destinationDir file("$buildDir/native-libs")
        baseName 'native-libs'
        from fileTree(dir: 'src/main/jnilibs', include: '**/*.so')
        into 'lib/'
    }

    tasks.withType(JavaCompile)
     {
          compileTask -> compileTask.dependsOn(nativeLibsToJar)
     }

这篇关于Android的NDK:如何包括AndroidStudio * .so文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆