Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AndroidStudio x NDK
Search
Takahiro Shimokawa
February 12, 2014
Programming
5
3.6k
AndroidStudio x NDK
How to execute "ndk-build" command by AndroidStudio.
Takahiro Shimokawa
February 12, 2014
Tweet
Share
More Decks by Takahiro Shimokawa
See All by Takahiro Shimokawa
PlayStoreでの新しいユーザー訴求 -LiveOpsの活用とその成果-
androhi
0
2.3k
ConcatAdapterを深掘る
androhi
1
360
Android Studio 4.1推しポイント!
androhi
0
1.2k
一人開発でつまづいたときの処方箋
androhi
0
290
Androidの物理ベースアニメーション
androhi
1
550
ConstraintLayout再入門
androhi
2
3.4k
Firebase Analytics 使用感
androhi
0
850
Support Library v23.2 overview
androhi
0
640
Support Library 総復習
androhi
2
2.4k
Other Decks in Programming
See All in Programming
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
200
C++でシェーダを書く
fadis
6
4.1k
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
340
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Jakarta EE meets AI
ivargrimstad
0
240
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
初めてDefinitelyTypedにPRを出した話
syumai
0
420
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
940
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
最新TCAキャッチアップ
0si43
0
200
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
110
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
73
9.1k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
How STYLIGHT went responsive
nonsquared
95
5.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
RailsConf 2023
tenderlove
29
900
Fireside Chat
paigeccino
34
3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
A better future with KSS
kneath
238
17k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Navigating Team Friction
lara
183
14k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Transcript
ANDROID STUDIO × NDK Լ ܟ߂ IN POTATOTIPS 4
ࣗݾհ • גࣜձࣾZaim • Android൛ΞϓϦ։ൃ
NFC HACK • ڞஶ • ن֨ɺ࣮ྫɺϋʔυΣΞ ɺ ιϑτΣΞ ɺηΩϡϦςΟ
ςʔϚ IDEΛͬͯANDROID NDKͱ࿈ܞ͢Δ
ࠓ·ͰͷྲྀΕ 1. EclipseͰNDKͱ࿈ܞ 2. AndroidStudioͰNDKͱ࿈ܞ ʢGradlePlugin0.7.0·Ͱʣ 3. AndroidStudioͰNDKͱ࿈ܞ ← ΠϚίί
ʢGradlePlugin0.7.3Ҏ߱ʣ
ECLIPSEͰNDK࿈ܞ • ϝϦοτ • ࣮ϊϋ͕๛ • σϝϦοτ • ͦͦEclipse͕ʢ͈́
࣮ྫ - ANDROID.MK LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS
:= tests LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_PACKAGE_NAME := HelloNDK LOCAL_SDK_VERSION := 14 LOCAL_JNI_SHARED_LIBRARIES := libhellondk include $(BUILD_PACKAGE) include $(LOCAL_PATH)/libhellondk/Android.mk
ANDROID STUDIOͰNDK࿈ܞ ʢV0.7.0·Ͱʣ • ϝϦοτ • EclipseͰ࡞ͨ͠ιʔεΛͦͷ··͑Δ • σϝϦοτ •
GradleͷԸܙΛड͚ͮΒ͍ • ProductFlavorͳͲ
࣮ྫ - BUILD.GRADLE // libsԼͷڞ༗ϥΠϒϥϦΛऔΓࠐΉ tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> pkgTask.jniDir
new File(buildDir, ‘native-libs') } // ndk-buildΛΒͤΔ task ndkBuild(type:Exec) { commandLine 'ndk-build' } tasks.withType(Compile) { compileTask -> compileTask.dependsOn ndkBuild }
ANDROID STUDIOͰNDK࿈ܞ ʢV0.7.3Ҏ߱ʣ • ϝϦοτ • build.gradleʹશͯهड़ग़དྷΔ • σϝϦοτ •
C/C++ͷίʔσΟϯάڥෆे
खॱ1 • ϑΥϧμߏ [Project] |-- src |-- main |-- java
|-- jni |— xxxx.c |-- xxxx.h |-- jniLibs |-- armeabi |-- xxxx.so |-- armeabi-v7a |-- mips |-- x86
खॱ2 • ύεઃఆ • ํ๏1: ANDROID_NDK_HOMEΛઃఆ ! • ํ๏2: local.propertiesʹه
ndk.dir=/xxxx/android-ndk-r9c export ANDROID_NDK_HOME=/xxxx/android-ndk-r9c
खॱ3 • build.gradleͷهड़ android { ... defaultConfig { ... ndk
{ moduleName "xxxx" ldLibs "dl", "log" stl "gnustl_shared" } } buildTypes.debug.jniDebugBuild true ... }
ϏϧυࡁΈڞ༗ϥΠϒϥϦΈࠐΈ • jniLibs͕σϑΥϧτϑΥϧμ໊ • ϏϧυࡁΈ .so ϑΝΠϧΛஔ͘ • ϑΥϧμ໊มߋՄೳ android
{ ... sourceSets.main { jniLibs.srcDir ‘src/main/libs’ } }
CPUΞʔΩςΫνϟͷࢦఆ • ϓϩμΫτʹඞཁͳͷ͚ͩੜ armv7 { ndk { abiFilter “armebi-v7a” }
} arm { ndk { abiFilter “armebi” } } } } android { ... ProductFlavors { x86 { ndk { abiFilter “x86” } } mips { ndk { abiFilter “mips” } }
ANDROID STUDIO͔ΒNDK-BUILD ΛࣗಈͰίʔϧ͢Δ • jniϑΥϧμʹιʔεϑΝΠϧΛஔ͚ͩ͘ • Android.mkෆཁ • Android.mkͱಉ༷ͷ੍ޚΛ͢Δʹbuild.gradleʹ هड़͢Δ
android { defaultConfig { ndk { moduleName “xxxx” } } }
BUILD.GRADLEʹهड़ग़དྷΔ߲ • moduleName • libxxxx.soͷ໊শ • ldLibs • ϦϯΫͤ͞ΔϥΠϒϥϦͷࢦఆ •
stl • ੜ͢ΔϥΠϒϥϦͷछผ • abiFilter(s) • CPUΞʔΩςΫνϟͷࢦఆ android { … defaultConfig { … ndk { moduleName “text” ldLibs “dl”, “log” stl “gnustl_shared” abiFilters “armebi”, “armebi-v7a } } }
ANDROID STUDIO͔ΒNDK-BUILD ΛࣗಈͰίʔϧͤ͞ͳ͍ android { … sourceSets.main.jni.srcDirs = [] }
ࢀߟࢿྉ • ANDROID STUDIO, GRADLE AND NDK INTEGRATION by ph0b’s
• Android Tools Project Site ͷαϯϓϧιʔε(gradle- sample-0.8.zip)