Skip to content

Commit 966ac86

Browse files
committed
better proj structure
1 parent f65d5fb commit 966ac86

File tree

3 files changed

+56
-33
lines changed

3 files changed

+56
-33
lines changed

build.gradle

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
buildscript {
44
repositories {
5-
jcenter()
5+
mavenCentral()
66
google()
77
}
88
dependencies {
@@ -15,7 +15,21 @@ buildscript {
1515

1616
allprojects {
1717
repositories {
18-
jcenter()
18+
mavenCentral()
1919
google()
2020
}
2121
}
22+
23+
ext {
24+
android = [
25+
compileSdkVersion: 30,
26+
buildToolsVersion: '30.0.2',
27+
minSdkVersion : 16,
28+
targetSdkVersion : 30,
29+
versionCode : 1,
30+
versionName : "1.0.0",
31+
applicationId : "org.wysaid.cgeDemo",
32+
appcompatV7 : "30.0.0",
33+
appcompatX : "1.2.0"
34+
]
35+
}

cgeDemo/build.gradle

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 25
4+
compileSdkVersion rootProject.ext.android.compileSdkVersion
5+
buildToolsVersion rootProject.ext.android.buildToolsVersion
56

67
defaultConfig {
7-
applicationId "org.wysaid.cgeDemo"
8-
minSdkVersion 14
9-
targetSdkVersion 22
10-
versionCode 1
11-
versionName "1.0"
8+
applicationId rootProject.ext.android.applicationId
9+
minSdkVersion rootProject.ext.android.minSdkVersion
10+
targetSdkVersion rootProject.ext.android.targetSdkVersion
11+
versionCode rootProject.ext.android.versionCode
12+
versionName rootProject.ext.android.versionName
1213
}
1314
buildTypes {
1415
release {
@@ -20,7 +21,8 @@ android {
2021
}
2122

2223
dependencies {
23-
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
compile 'com.android.support:appcompat-v7:25.2.0'
25-
compile project(':library')
24+
implementation fileTree(dir: 'libs', include: ['*.jar'])
25+
implementation project(':library')
26+
implementation 'com.android.support:appcompat-v7:' + rootProject.ext.android.appcompatV7
27+
implementation 'androidx.appcompat:appcompat:' + rootProject.ext.android.appcompatX
2628
}

library/build.gradle

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,38 @@ def usingCMakeCompile() {
66
}
77

88
android {
9-
compileSdkVersion 25
10-
if(usingCMakeCompile()) {
9+
compileSdkVersion rootProject.ext.android.compileSdkVersion
10+
buildToolsVersion rootProject.ext.android.buildToolsVersion
11+
12+
if (usingCMakeCompile()) {
1113
ndkVersion "23.1.7779620"
1214
}
1315

1416
defaultConfig {
15-
minSdkVersion 14
16-
targetSdkVersion 22
17-
versionCode 1
18-
versionName "2.4.6"
17+
minSdkVersion rootProject.ext.android.minSdkVersion
18+
targetSdkVersion rootProject.ext.android.targetSdkVersion
19+
versionCode rootProject.ext.android.versionCode
20+
versionName rootProject.ext.android.versionName
1921

20-
externalNativeBuild {
21-
cmake {
22-
arguments "-DCGE_USE_VIDEO_MODULE=1",
23-
"-DANDROID_STL=c++_static",
24-
"-DANDROID_ARM_NEON=TRUE",
25-
"-DANDROID_GRADLE=1"
22+
if (usingCMakeCompile()) {
23+
externalNativeBuild {
24+
cmake {
25+
arguments "-DCGE_USE_VIDEO_MODULE=1",
26+
"-DANDROID_STL=c++_static",
27+
"-DANDROID_ARM_NEON=TRUE",
28+
"-DANDROID_GRADLE=1"
2629

27-
cppFlags "-frtti -std=c++14"
30+
cppFlags "-frtti -std=c++14"
31+
}
2832
}
2933
}
3034
}
31-
externalNativeBuild {
32-
cmake {
33-
path 'src/main/jni/CMakeLists.txt'
35+
36+
if (usingCMakeCompile()) {
37+
externalNativeBuild {
38+
cmake {
39+
path 'src/main/jni/CMakeLists.txt'
40+
}
3441
}
3542
}
3643

@@ -44,12 +51,11 @@ android {
4451
////////////////////////////////////////
4552

4653
sourceSets.main {
47-
if(usingCMakeCompile()) {
54+
if (usingCMakeCompile()) {
4855
jniLibs.srcDir 'src/main/libs' //set libs as .so's location instead of jni
49-
}
50-
else {
56+
} else {
5157
jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk file
52-
}
58+
}
5359
}
5460
compileOptions {
5561
sourceCompatibility JavaVersion.VERSION_1_8
@@ -58,6 +64,7 @@ android {
5864
}
5965

6066
dependencies {
61-
compile fileTree(dir: 'libs', include: ['*.jar'])
62-
compile 'com.android.support:appcompat-v7:25.2.0'
67+
implementation fileTree(dir: 'libs', include: ['*.jar'])
68+
implementation 'com.android.support:appcompat-v7:' + rootProject.ext.android.appcompatV7
69+
implementation 'androidx.appcompat:appcompat:' + rootProject.ext.android.appcompatX
6370
}

0 commit comments

Comments
 (0)