NDK: how include *.so files in AndroidStudio

前端 未结 4 600
耶瑟儿~
耶瑟儿~ 2020-11-29 10:50

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 i

4条回答
  •  情深已故
    2020-11-29 11:23

    Three options:

    One

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

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

    Two

    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 
        }//sourceSets tag close
    }//Android tag close
    

    There

    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)
         }
    

提交回复
热议问题