简体   繁体   中英

android studio 1.3 RC, NDK prebuilt libraries

I would like to use Android Studio 1.3 RC to write native code. But I cannot find any sample about how to add prebuilt libraries in Gradle. Anyone have idea about this?

I want to use ffmpeg prebuilt library in my project. I still use Android.mk to build my so now.

You may clone samples at https://github.com/googlesamples/android-ndk.git , according to android studio doc http://tools.android.com/tech-docs/android-ndk-preview .

You had errors compiling the samples until I append

tasks.withType(JavaCompile) {
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7
}

to build.gradle (app).

Android Studio: New gradle build NDK sample app error

Finally, I solved the problem.

First, add prebuilt libraries to src/main/jniLibs.

Second, write app/build.gradle

android.ndk {
    moduleName = "test"
    //add head files
    cppFlags +="-I${file("src/main/jni/ffmpeg/include")}".toString()

    //add prebuilt library
    ldLibs += file("src/main/jniLibs/armeabi-v7a/libffmpeg.so").toString()
    ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM