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.5k
ConcatAdapterを深掘る
androhi
1
400
Android Studio 4.1推しポイント!
androhi
0
1.3k
一人開発でつまづいたときの処方箋
androhi
0
330
Androidの物理ベースアニメーション
androhi
1
580
ConstraintLayout再入門
androhi
2
3.5k
Firebase Analytics 使用感
androhi
0
870
Support Library v23.2 overview
androhi
0
670
Support Library 総復習
androhi
2
2.5k
Other Decks in Programming
See All in Programming
複数ドメインに散らばってしまった画像…! 運用中のPHPアプリに後からCDNを導入する…!
suguruooki
0
440
보일러플레이트 코드가 진짜 나쁜 건가요?
gaeun5744
0
370
OUPC2024 Day 1 解説
kowerkoint
0
400
ローコードサービスの進化のためのモノレポ移行
taro28
1
340
DomainException と Result 型で作る型安全なエラーハンドリング
karszawa
0
540
本当だってば!俺もTRICK 2022に入賞してたんだってば!
jinroq
0
260
英語文法から学ぶ、クリーンな設計の秘訣
newnomad
1
270
List とは何か? / PHPerKaigi 2025
meihei3
0
560
PsySHから紐解くREPLの仕組み
muno92
PRO
1
530
Windows版PHPのビルド手順とPHP 8.4における変更点
matsuo_atsushi
0
370
eBPF Updates (March 2025)
kentatada
0
130
AtCoder Heuristic First-step Vol.1 講義スライド
terryu16
2
1k
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
522
39k
The World Runs on Bad Software
bkeepers
PRO
67
11k
Building a Modern Day E-commerce SEO Strategy
aleyda
39
7.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
The Invisible Side of Design
smashingmag
299
50k
Into the Great Unknown - MozCon
thekraken
36
1.7k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.4k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
29
2k
Designing for Performance
lara
606
69k
Java REST API Framework Comparison - PWX 2021
mraible
29
8.5k
Side Projects
sachag
452
42k
The Cult of Friendly URLs
andyhume
78
6.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)