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
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
460
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
命名をリントする
chiroruxx
1
390
php-conference-japan-2024
tasuku43
0
230
Recoilを剥がしている話
kirik
5
6.6k
たのしいparse.y
ydah
3
120
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
320
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
130
ドメインイベント増えすぎ問題
h0r15h0
1
250
Haze - Real time background blurring
chrisbanes
1
510
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
Featured
See All Featured
Building Your Own Lightsaber
phodgson
103
6.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Scaling GitHub
holman
458
140k
Unsuck your backbone
ammeep
669
57k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
BBQ
matthewcrist
85
9.4k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Typedesign – Prime Four
hannesfritz
40
2.4k
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)