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.7k
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
370
Android Studio 4.1推しポイント!
androhi
0
1.2k
一人開発でつまづいたときの処方箋
androhi
0
300
Androidの物理ベースアニメーション
androhi
1
560
ConstraintLayout再入門
androhi
2
3.4k
Firebase Analytics 使用感
androhi
0
850
Support Library v23.2 overview
androhi
0
650
Support Library 総復習
androhi
2
2.4k
Other Decks in Programming
See All in Programming
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
490
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
140
Security_for_introducing_eBPF
kentatada
0
110
fs2-io を試してたらバグを見つけて直した話
chencmd
0
240
どうして手を動かすよりもチーム内のコードレビューを優先するべきなのか
okashoi
3
160
良いユニットテストを書こう
mototakatsu
8
2.7k
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
260
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
140
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
100
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
useSyncExternalStoreを使いまくる
ssssota
6
1.2k
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
450
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Optimising Largest Contentful Paint
csswizardry
33
3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Building an army of robots
kneath
302
44k
The Language of Interfaces
destraynor
154
24k
RailsConf 2023
tenderlove
29
940
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Site-Speed That Sticks
csswizardry
2
190
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)