概要
vistaでandroid studio 1.1.0やってみた。
jniが、やりたいので調査。
jniの仕組み
cソースをコンパイルして、soを作る。
- ndkをインストール。
- src/main/jniフォルダを作る。
- src/main/libsフォルダを作る。
- hello.cを書く。
- Android.mkを書く。
- ndk-buildにpathを通す。
- ndk-buildを実行して、hello.soを作る。
apkにsoを挿入する。
- gradleを書いて、soを挿入。
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDir "src/main/libs"
}
}
javaソースを、書いて、jniを呼び出す。
- System.loadLibrary("hello")
- private native
以上。