Skip to content

Commit dcd4f2f

Browse files
committed
Updating c++ samples to use NDKbuild from Android Studio.
These samples require NDK version r10e or eariler, so CMake cannot be used. Change-Id: Iffaab664e44e2353f120184a0e0c374adc8cee33
1 parent 165f8be commit dcd4f2f

File tree

20 files changed

+125
-525
lines changed

20 files changed

+125
-525
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ obj/
99

1010
.gradle/
1111
build/
12+
.externalNativeBuild/
1213

1314
*.iml
1415

Lines changed: 19 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apply plugin: 'com.android.model.application'
1+
apply plugin: 'com.android.application'
22

33
// Depend on another project that downloads and unzips the C++ SDK.
44
evaluationDependsOn(':Common/gpg-sdk')
@@ -12,80 +12,31 @@ tasks.whenTaskAdded { task ->
1212
}
1313
}
1414

15-
def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
16-
17-
// stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"]
18-
// used to set stl and location of libgpg.a
19-
def stlportType = "c++"
20-
def stllinkType = "static"
21-
22-
model {
23-
repositories {
24-
libs(PrebuiltLibraries) {
25-
gpg {
26-
headers.srcDir "${gpg_cpp_path}/include"
27-
binaries.withType(StaticLibraryBinary) {
28-
staticLibraryFile = file("${gpg_cpp_path}/lib/${stlportType}/${targetPlatform.getName()}/libgpg.a")
29-
}
30-
}
15+
android {
16+
compileSdkVersion 23
17+
buildToolsVersion '23.0.2'
18+
defaultConfig {
19+
//
20+
// REPLACE THE APPLICATION ID with your bundle ID
21+
//
22+
applicationId "com.google.example.games.ReplaceMe"
23+
minSdkVersion 14
24+
targetSdkVersion 23
25+
26+
ndk {
27+
abiFilters 'x86', 'armeabi-v7a'
3128
}
3229
}
33-
android {
34-
compileSdkVersion=23
35-
buildToolsVersion="23.0.2"
3630

37-
defaultConfig.with {
38-
//
39-
// REPLACE THE APPLICATION ID with your bundle ID
40-
//
41-
applicationId="com.google.example.games.ReplaceMe"
42-
minSdkVersion.apiLevel = 11
43-
targetSdkVersion.apiLevel = 23
44-
}
45-
}
46-
android.sources {
47-
main {
48-
jni {
49-
dependencies {
50-
library "gpg" linkage "static"
51-
project ":Common/cpufeatures" linkage "static"
52-
project ":Common/native_app_glue" linkage "static"
53-
}
54-
source {
55-
srcDir 'src/main/jni'
56-
srcDir '../Common/ndk_helper'
57-
srcDir '../Common/jui_helper'
58-
}
59-
}
60-
}
61-
}
62-
android.ndk {
63-
platformVersion = 11
64-
moduleName = "ButtonClickerNativeActivity"
65-
stl = "${stlportType}_${stllinkType}"
66-
ldLibs.addAll(["atomic", "log", "android", "EGL", "GLESv2", "z"])
67-
abiFilters.addAll(["armeabi", "armeabi-v7a", "x86", "arm64-v8a"])
68-
cppFlags.addAll(["-std=c++11",
69-
"-I${file("../Common/ndk_helper")}".toString(),
70-
"-I${file("../Common/jui_helper")}".toString() ])
71-
}
72-
android.buildTypes {
73-
release {
74-
minifyEnabled=false
75-
proguardFiles.add(file('proguard-android.txt'))
76-
}
77-
}
78-
android.abis {
79-
create("armeabi-v7a") {
80-
cppFlags.addAll(["-mhard-float", "-D_NDK_MATH_NO_SOFTFP=1", "-mfloat-abi=hard"])
81-
ldLibs.add("m_hard")
82-
ldFlags.add("-Wl,--no-warn-mismatch")
31+
externalNativeBuild {
32+
ndkBuild {
33+
path 'src/main/jni/Android.mk'
8334
}
8435
}
8536
}
8637

8738
dependencies {
88-
compile 'com.google.android.gms:play-services-games:8.4.0'
89-
compile 'com.google.android.gms:play-services-nearby:8.4.0'
39+
compile 'com.google.android.gms:play-services-games:10.0.0'
40+
compile 'com.google.android.gms:play-services-nearby:10.0.0'
9041
compile 'com.android.support:support-v4:23.1.1'
9142
}

samples-android/ButtonClicker/src/main/jni/Android.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ endif
2727

2828
include $(BUILD_SHARED_LIBRARY)
2929

30+
include $(LOCAL_PATH)/../../../../Common/gpg-sdk/gpg-cpp-sdk/android/Android.mk
31+
3032
$(call import-add-path,$(LOCAL_PATH)/../../../../Common)
3133
$(call import-module,ndk_helper)
3234
$(call import-module,jui_helper)
33-
$(call import-module,gpg-cpp-sdk/android)
3435
$(call import-module,android/native_app_glue)
3536
$(call import-module,android/cpufeatures)
Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apply plugin: 'com.android.model.application'
1+
apply plugin: 'com.android.application'
22

33
// Depend on another project that downloads and unzips the C++ SDK.
44
evaluationDependsOn(':Common/gpg-sdk')
@@ -12,83 +12,31 @@ tasks.whenTaskAdded { task ->
1212
}
1313
}
1414

15-
def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"
15+
android {
16+
compileSdkVersion 23
17+
buildToolsVersion '23.0.2'
18+
defaultConfig {
19+
//
20+
// REPLACE THE APPLICATION ID with your bundle ID
21+
//
22+
applicationId "com.google.example.games.ReplaceMe"
23+
minSdkVersion 14
24+
targetSdkVersion 23
1625

17-
// stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"]
18-
// used to set stl and location of libgpg.a
19-
def stlportType = "c++"
20-
def stllinkType = "static"
21-
22-
model {
23-
repositories {
24-
libs(PrebuiltLibraries) {
25-
gpg {
26-
headers.srcDir "${gpg_cpp_path}/include"
27-
binaries.withType(StaticLibraryBinary) {
28-
staticLibraryFile = file("${gpg_cpp_path}/lib/${stlportType}/${targetPlatform.getName()}/libgpg.a")
29-
}
30-
}
26+
ndk {
27+
abiFilters 'x86', 'armeabi-v7a'
3128
}
3229
}
33-
android {
34-
compileSdkVersion = 23
35-
buildToolsVersion = "23.0.2"
3630

37-
defaultConfig.with {
38-
//
39-
// REPLACE THE APPLICATION ID with your bundle ID
40-
//
41-
applicationId="com.google.example.games.ReplaceMe"
42-
minSdkVersion.apiLevel = 11
43-
targetSdkVersion.apiLevel = 23
44-
versionCode = 1.0
45-
versionName = '1.0'
46-
}
47-
}
48-
android.sources {
49-
main {
50-
jni {
51-
dependencies {
52-
library "gpg" linkage "static"
53-
project ":Common/cpufeatures" linkage "static"
54-
project ":Common/native_app_glue" linkage "static"
55-
}
56-
source {
57-
srcDir 'src/main/jni'
58-
srcDir '../Common/ndk_helper'
59-
srcDir '../Common/jui_helper'
60-
srcDir '../Common/external/jsoncpp/src/lib_json'
61-
}
62-
}
63-
}
64-
}
65-
android.ndk {
66-
platformVersion = 11
67-
moduleName ="CollectAllTheStarsNativeActivity"
68-
stl = "${stlportType}_${stllinkType}"
69-
ldLibs.addAll(["atomic", "log", "android", "EGL", "GLESv2", "z"])
70-
abiFilters.addAll(["armeabi", "armeabi-v7a","arm64-v8a", "x86"])
71-
cppFlags.addAll(["-std=c++11",
72-
"-I${file("../Common/external/jsoncpp/include")}".toString(),
73-
"-I${file("../Common/ndk_helper")}".toString(),
74-
"-I${file("../Common/jui_helper")}".toString() ])
75-
}
76-
android.abis {
77-
create("armeabi-v7a") {
78-
cppFlags.addAll(["-mhard-float", "-D_NDK_MATH_NO_SOFTFP=1", "-mfloat-abi=hard"])
79-
ldLibs.add("m_hard")
80-
ldFlags.add("-Wl,--no-warn-mismatch")
81-
}
82-
}
83-
android.buildTypes {
84-
release {
85-
minifyEnabled=false
86-
proguardFiles.add(file('proguard-android.txt'))
31+
externalNativeBuild {
32+
ndkBuild {
33+
path 'src/main/jni/Android.mk'
8734
}
8835
}
8936
}
37+
9038
dependencies {
91-
compile 'com.google.android.gms:play-services-games:8.4.0'
92-
compile 'com.google.android.gms:play-services-plus:8.4.0'
39+
compile 'com.google.android.gms:play-services-games:10.0.0'
40+
compile 'com.google.android.gms:play-services-nearby:10.0.0'
9341
compile 'com.android.support:support-v4:23.1.1'
9442
}

samples-android/CollectAllTheStarsNative/src/main/jni/Android.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ endif
3131

3232
include $(BUILD_SHARED_LIBRARY)
3333

34+
include $(LOCAL_PATH)/../../../../Common/gpg-sdk/gpg-cpp-sdk/android/Android.mk
35+
3436
$(call import-add-path,$(LOCAL_PATH)/../../../../Common)
3537
$(call import-module,ndk_helper)
3638
$(call import-module,jui_helper)
37-
$(call import-module,gpg-cpp-sdk/android)
3839
$(call import-module,android/native_app_glue)
3940
$(call import-module,android/cpufeatures)

samples-android/Common/cpufeatures/build.gradle

Lines changed: 0 additions & 42 deletions
This file was deleted.

samples-android/Common/native_app_glue/build.gradle

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)