-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
123 lines (111 loc) · 3.26 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* @author [email protected]
*/
// General gradle arguments for root project
repositories {
google()
jcenter()
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
}
// Output: Android JNI library
apply plugin: 'com.android.library'
android {
compileSdkVersion 25 // Android 7.1.1
// External Native build
// - using Gradle's CMake plugin
// - Give path to CMake
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
// Target ABI
// - This option controls target platform of module
// - The platform might not supported by the compiler
// some can work with Clang(default), but some can work only with GCC...
// if bad, both toolchains might not support it
splits {
abi {
// disable all
enable true
universalApk true
reset()
// we can include multiple platform, like...
include "armeabi-v7a", "arm64-v8a", "x86_64"
}
}
defaultConfig {
minSdkVersion 21 // Android 5.0+
targetSdkVersion 25 // Follow Compile SDK
// Follow native code's verson
versionCode 25
versionName "1.1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// External Native build: CMake
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared"
}
}
println(externalNativeBuild.cmake.cppFlags)
}
println(defaultConfig.versionName)
// Custom SourceSet
// - Source path/directory for Gradle
sourceSets {
main.setRoot('android')
main {
manifest.srcFile 'android/AndroidManifest.xml'
java.srcDirs = ['android/java']
jni.srcDirs = ['android/jni']
jniLibs.srcDirs = ['android/jniLibs']
res.srcDirs = ['android/res']
assets.srcDirs = ['android/assets']
}
// gradle connectedAndroidTest
androidTest.setRoot('android/test')
androidTest {
java.srcDir 'android/test/java'
jniLibs.srcDirs = ['android/jniLibs', 'libs']
}
}
// buildToolsVersion '26.0.1'
testOptions {
unitTests.all {
// All the usual Gradle options.
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}
assemble.doLast
{
// Instead of `ninja install`, Gradle will deploy the files.
copy {
from 'build/intermediates/cmake/debug/obj'
into 'install/libs/Debug'
}
copy {
from 'build/intermediates/cmake/release/obj'
into 'install/libs/Release'
}
// delete '.externalNativeBuild'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// Follow target SDK
implementation 'com.android.support:appcompat-v7:25.4.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}