Skip to content

Commit

Permalink
Updating c++ samples to use NDKbuild from Android Studio.
Browse files Browse the repository at this point in the history
These samples require NDK version r10e or eariler, so CMake cannot be used.

Change-Id: Iffaab664e44e2353f120184a0e0c374adc8cee33
  • Loading branch information
claywilkinson committed Dec 7, 2016
1 parent 165f8be commit dcd4f2f
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 525 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ obj/

.gradle/
build/
.externalNativeBuild/

*.iml

Expand Down
87 changes: 19 additions & 68 deletions samples-android/ButtonClicker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply plugin: 'com.android.model.application'
apply plugin: 'com.android.application'

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

def gpg_cpp_path = file(project(':Common/gpg-sdk').projectDir).absolutePath + "/gpg-cpp-sdk/android"

// stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"]
// used to set stl and location of libgpg.a
def stlportType = "c++"
def stllinkType = "static"

model {
repositories {
libs(PrebuiltLibraries) {
gpg {
headers.srcDir "${gpg_cpp_path}/include"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("${gpg_cpp_path}/lib/${stlportType}/${targetPlatform.getName()}/libgpg.a")
}
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
//
// REPLACE THE APPLICATION ID with your bundle ID
//
applicationId "com.google.example.games.ReplaceMe"
minSdkVersion 14
targetSdkVersion 23

ndk {
abiFilters 'x86', 'armeabi-v7a'
}
}
android {
compileSdkVersion=23
buildToolsVersion="23.0.2"

defaultConfig.with {
//
// REPLACE THE APPLICATION ID with your bundle ID
//
applicationId="com.google.example.games.ReplaceMe"
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 23
}
}
android.sources {
main {
jni {
dependencies {
library "gpg" linkage "static"
project ":Common/cpufeatures" linkage "static"
project ":Common/native_app_glue" linkage "static"
}
source {
srcDir 'src/main/jni'
srcDir '../Common/ndk_helper'
srcDir '../Common/jui_helper'
}
}
}
}
android.ndk {
platformVersion = 11
moduleName = "ButtonClickerNativeActivity"
stl = "${stlportType}_${stllinkType}"
ldLibs.addAll(["atomic", "log", "android", "EGL", "GLESv2", "z"])
abiFilters.addAll(["armeabi", "armeabi-v7a", "x86", "arm64-v8a"])
cppFlags.addAll(["-std=c++11",
"-I${file("../Common/ndk_helper")}".toString(),
"-I${file("../Common/jui_helper")}".toString() ])
}
android.buildTypes {
release {
minifyEnabled=false
proguardFiles.add(file('proguard-android.txt'))
}
}
android.abis {
create("armeabi-v7a") {
cppFlags.addAll(["-mhard-float", "-D_NDK_MATH_NO_SOFTFP=1", "-mfloat-abi=hard"])
ldLibs.add("m_hard")
ldFlags.add("-Wl,--no-warn-mismatch")
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
}

dependencies {
compile 'com.google.android.gms:play-services-games:8.4.0'
compile 'com.google.android.gms:play-services-nearby:8.4.0'
compile 'com.google.android.gms:play-services-games:10.0.0'
compile 'com.google.android.gms:play-services-nearby:10.0.0'
compile 'com.android.support:support-v4:23.1.1'
}
3 changes: 2 additions & 1 deletion samples-android/ButtonClicker/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ endif

include $(BUILD_SHARED_LIBRARY)

include $(LOCAL_PATH)/../../../../Common/gpg-sdk/gpg-cpp-sdk/android/Android.mk

$(call import-add-path,$(LOCAL_PATH)/../../../../Common)
$(call import-module,ndk_helper)
$(call import-module,jui_helper)
$(call import-module,gpg-cpp-sdk/android)
$(call import-module,android/native_app_glue)
$(call import-module,android/cpufeatures)
90 changes: 19 additions & 71 deletions samples-android/CollectAllTheStarsNative/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply plugin: 'com.android.model.application'
apply plugin: 'com.android.application'

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

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

// stlport configuration ["c++_static", "c++_shared", "gnustl_static", "gnustl_shared"]
// used to set stl and location of libgpg.a
def stlportType = "c++"
def stllinkType = "static"

model {
repositories {
libs(PrebuiltLibraries) {
gpg {
headers.srcDir "${gpg_cpp_path}/include"
binaries.withType(StaticLibraryBinary) {
staticLibraryFile = file("${gpg_cpp_path}/lib/${stlportType}/${targetPlatform.getName()}/libgpg.a")
}
}
ndk {
abiFilters 'x86', 'armeabi-v7a'
}
}
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"

defaultConfig.with {
//
// REPLACE THE APPLICATION ID with your bundle ID
//
applicationId="com.google.example.games.ReplaceMe"
minSdkVersion.apiLevel = 11
targetSdkVersion.apiLevel = 23
versionCode = 1.0
versionName = '1.0'
}
}
android.sources {
main {
jni {
dependencies {
library "gpg" linkage "static"
project ":Common/cpufeatures" linkage "static"
project ":Common/native_app_glue" linkage "static"
}
source {
srcDir 'src/main/jni'
srcDir '../Common/ndk_helper'
srcDir '../Common/jui_helper'
srcDir '../Common/external/jsoncpp/src/lib_json'
}
}
}
}
android.ndk {
platformVersion = 11
moduleName ="CollectAllTheStarsNativeActivity"
stl = "${stlportType}_${stllinkType}"
ldLibs.addAll(["atomic", "log", "android", "EGL", "GLESv2", "z"])
abiFilters.addAll(["armeabi", "armeabi-v7a","arm64-v8a", "x86"])
cppFlags.addAll(["-std=c++11",
"-I${file("../Common/external/jsoncpp/include")}".toString(),
"-I${file("../Common/ndk_helper")}".toString(),
"-I${file("../Common/jui_helper")}".toString() ])
}
android.abis {
create("armeabi-v7a") {
cppFlags.addAll(["-mhard-float", "-D_NDK_MATH_NO_SOFTFP=1", "-mfloat-abi=hard"])
ldLibs.add("m_hard")
ldFlags.add("-Wl,--no-warn-mismatch")
}
}
android.buildTypes {
release {
minifyEnabled=false
proguardFiles.add(file('proguard-android.txt'))
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
}

dependencies {
compile 'com.google.android.gms:play-services-games:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-games:10.0.0'
compile 'com.google.android.gms:play-services-nearby:10.0.0'
compile 'com.android.support:support-v4:23.1.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ endif

include $(BUILD_SHARED_LIBRARY)

include $(LOCAL_PATH)/../../../../Common/gpg-sdk/gpg-cpp-sdk/android/Android.mk

$(call import-add-path,$(LOCAL_PATH)/../../../../Common)
$(call import-module,ndk_helper)
$(call import-module,jui_helper)
$(call import-module,gpg-cpp-sdk/android)
$(call import-module,android/native_app_glue)
$(call import-module,android/cpufeatures)
42 changes: 0 additions & 42 deletions samples-android/Common/cpufeatures/build.gradle

This file was deleted.

51 changes: 0 additions & 51 deletions samples-android/Common/native_app_glue/build.gradle

This file was deleted.

Loading

0 comments on commit dcd4f2f

Please sign in to comment.