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
RubyLSPのマルチバイト文字対応
notfounds
0
120
距離関数を極める! / SESSIONS 2024
gam0022
0
280
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
280
Amazon Qを使ってIaCを触ろう!
maruto
0
400
C++でシェーダを書く
fadis
6
4.1k
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
Better Code Design in PHP
afilina
PRO
0
120
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
EventSourcingの理想と現実
wenas
6
2.3k
Jakarta EE meets AI
ivargrimstad
0
140
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
How GitHub (no longer) Works
holman
310
140k
BBQ
matthewcrist
85
9.3k
Fireside Chat
paigeccino
34
3k
How to Ace a Technical Interview
jacobian
276
23k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Optimizing for Happiness
mojombo
376
70k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
KATA
mclloyd
29
14k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
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)