@@ -3,6 +3,13 @@ apply plugin: 'com.android.application'
3
3
android {
4
4
compileSdkVersion rootProject. ext. compileSdkVersion
5
5
buildToolsVersion rootProject. ext. buildToolsVersion
6
+
7
+ // 使用 JDK 1.8
8
+ // compileOptions {
9
+ // targetCompatibility JavaVersion.VERSION_1_8
10
+ // sourceCompatibility JavaVersion.VERSION_1_8
11
+ // }
12
+
6
13
defaultConfig {
7
14
// 无痛修改包名:https://www.jianshu.com/p/17327e191d2e
8
15
applicationId " com.hjq.demo"
@@ -11,6 +18,16 @@ android {
11
18
versionCode 10
12
19
versionName " 1.0"
13
20
testInstrumentationRunner " android.support.test.runner.AndroidJUnitRunner"
21
+
22
+ // 混淆配置
23
+ proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-app.pro'
24
+
25
+ javaCompileOptions {
26
+ annotationProcessorOptions {
27
+ // EventBus Apt 索引类生成位置
28
+ arguments = [ eventBusIndex : applicationId + ' .MyEventBusIndex' ]
29
+ }
30
+ }
14
31
}
15
32
16
33
// APK 签名的那些事:https://www.jianshu.com/p/a1f8e5896aa2
@@ -39,33 +56,29 @@ android {
39
56
zipAlignEnabled true
40
57
// 设置混淆
41
58
minifyEnabled true
42
- // 加载默认混淆配置涵
43
- proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
44
59
// 正式环境签名
45
60
// signingConfig signingConfigs.release
46
61
}
47
62
48
63
debug {
49
- // ZipAlign优化
64
+ // ZipAlign优化
50
65
zipAlignEnabled false
51
- // 设置混淆
66
+ // 设置混淆
52
67
minifyEnabled false
53
- // 加载默认混淆配置涵
54
- proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
55
68
// 开发环境签名
56
69
// signingConfig signingConfigs.debug
57
70
}
58
71
}
59
72
60
- flavorDimensions " default" // 这个名字貌似随便取,也可以有多个,总之一定要有
61
- // 多渠道打包
73
+ flavorDimensions " default" // 这个名字貌似随便取,也可以有多个,总之一定要有
74
+ // 友盟多渠道打包
62
75
productFlavors {
63
- kuan {} // 酷安
64
- tencent {} // 应用宝
65
- baidu {} // 百度
66
- xiaomi {} // 小米
67
- huawei {} // 华为
68
- google {} // 谷歌
76
+ kuan {} // 酷安
77
+ tencent {} // 应用宝
78
+ baidu {} // 百度
79
+ xiaomi {} // 小米
80
+ huawei {} // 华为
81
+ google {} // 谷歌
69
82
70
83
productFlavors. all { flavor ->
71
84
flavor. manifestPlaceholders = [UMENG_CHANNEL_VALUE : name]
@@ -78,69 +91,102 @@ android {
78
91
jniLibs. srcDirs = [' libs' ]
79
92
}
80
93
}
94
+
95
+ // 执行配置
96
+ applicationVariants. all { variant ->
97
+
98
+ // Apk 输出配置
99
+ variant. outputs. all { output ->
100
+ def appName = " AndroidProject"
101
+ if (variant. buildType. name == ' debug' ) {
102
+ outputFileName = appName + ' _v' + versionName + ' _' + variant. buildType. name + ' .apk'
103
+ } else {
104
+ outputFileName = appName + ' _v' + versionName + ' _' + new Date (). format(" yyyyMMdd" ) + ' _' + variant. productFlavors[0 ]. name + ' _' + variant. buildType. name + ' .apk'
105
+ }
106
+ }
107
+
108
+ // AndroidManifest 输出配置
109
+ variant. outputs[0 ]. processManifest. doLast {
110
+ def manifestFile = " ${ manifestOutputDirectory} /AndroidManifest.xml"
111
+ def updatedContent = new File (manifestFile). getText(' UTF-8' )
112
+ .replaceAll(" UMENG_APPKEY_VALUE" , " 5cb16d93570df399fd0014e2" ) // 友盟 AppKey
113
+ .replaceAll(" QQ_APPID_VALUE" , " 100424468" ) // QQ AppId
114
+ .replaceAll(" QQ_APPKEY_VALUE" , " c7394704798a158208a74ab60104f0ba" ) // QQ Key
115
+ .replaceAll(" WX_APPID_VALUE" , " wxdc1e388c3822c80b" ) // 微信 AppId
116
+ .replaceAll(" WX_APPKEY_VALUE" , " 3baf1193c85774b3fd9d18447d76cab0" ) // 微信 Key
117
+ .replaceAll(" SN_APPID_VALUE" , " 3921700954" ) // 新浪 AppId
118
+ .replaceAll(" SN_APPKEY_VALUE" , " 04b48b094faeb16683c32669824ebdad" ) // 新浪 Key
119
+ new File (manifestFile). write(updatedContent, ' UTF-8' )
120
+ }
121
+ }
81
122
}
82
123
83
- // api 与 implementation的区别 :https://www.jianshu.com/p/8962d6ba936e
124
+ // api 与 implementation 的区别 :https://www.jianshu.com/p/8962d6ba936e
84
125
dependencies {
85
- // 依赖 libs 目录下所有 Jar 包
126
+ // 依赖 libs 目录下所有 jar 包
86
127
implementation fileTree(include : [' *.jar' ], dir : ' libs' )
128
+ // 依赖 libs 目录下所有 aar 包
129
+ implementation fileTree(include : [' *.aar' ], dir : ' libs' )
130
+
87
131
// 基础库(不包任何第三方框架)
88
132
implementation project(' :base' )
89
133
// 自定义 View
90
134
implementation project(' :widget' )
91
- // 图片加载封装
135
+ // Dialog 封装
136
+ implementation project(' :dialog' )
137
+ // Glide 隔离
92
138
implementation project(' :image' )
93
- // 友盟
139
+ // 友盟隔离
94
140
implementation project(' :umeng' )
95
- // Dialog
96
- implementation project(' :dialog' )
97
-
98
- // 示例:添加一个 aar 包
99
- // implementation(name: 'library', ext: 'aar')
100
141
101
142
implementation " com.android.support:appcompat-v7:$rootProject . ext . supportLibraryVersion "
102
143
implementation " com.android.support:design:$rootProject . ext . supportLibraryVersion "
103
144
implementation " com.android.support:support-v4:$rootProject . ext . supportLibraryVersion "
104
145
implementation " com.android.support:cardview-v7:$rootProject . ext . supportLibraryVersion "
105
146
implementation " com.android.support.constraint:constraint-layout:$rootProject . ext . constraintLayoutVersion "
106
147
107
- // Dex分包,解决 65k 问题
148
+ // Dex分包,解决 64k 问题
108
149
implementation ' com.android.support:multidex:1.0.3'
109
150
110
- // ButterKnife注解库 :https://github.com/JakeWharton/butterknife
151
+ // ButterKnife 注解库 :https://github.com/JakeWharton/butterknife
111
152
implementation ' com.jakewharton:butterknife:9.0.0-rc1'
112
153
annotationProcessor ' com.jakewharton:butterknife-compiler:9.0.0-rc1'
113
154
155
+ // EventBus 事件总线
156
+ implementation " org.greenrobot:eventbus:3.1.1"
157
+ annotationProcessor ' org.greenrobot:eventbus-annotation-processor:3.1.1'
158
+
114
159
// 状态栏沉浸:https://github.com/gyf-dev/ImmersionBar
115
160
implementation ' com.gyf.immersionbar:immersionbar:2.3.3'
116
161
// 侧滑功能:https://github.com/bingoogolapple/BGASwipeBackLayout-Android
117
162
implementation ' cn.bingoogolapple:bga-swipebacklayout:1.2.0'
118
163
119
164
// 权限请求框架:https://github.com/getActivity/XXPermissions
120
- implementation ' com.hjq:xxpermissions:latest.integration '
165
+ implementation ' com.hjq:xxpermissions:5.5 '
121
166
// 标题栏:https://github.com/getActivity/TitleBar
122
- implementation ' com.hjq:titlebar:latest.integration '
167
+ implementation ' com.hjq:titlebar:5.0 '
123
168
// 吐司工具类:https://github.com/getActivity/ToastUtils
124
- implementation ' com.hjq:toast:latest.integration '
169
+ implementation ' com.hjq:toast:6.0 '
125
170
126
171
// 圆形的ImageView:https://github.com/hdodenhof/CircleImageView
127
172
implementation ' de.hdodenhof:circleimageview:2.2.0'
128
173
174
+ // 支持放大缩放的ImageView:https://github.com/chrisbanes/PhotoView
175
+ implementation ' com.github.chrisbanes:PhotoView:2.0.0'
176
+
177
+ // 布局优化:https://github.com/getActivity/Layouts
178
+ // 分割线:https://github.com/getActivity/RecyclerItemDecoration
179
+ // 国际化:https://github.com/getActivity/MultiLanguages
129
180
// 悬浮窗:https://github.com/getActivity/XToast
130
181
// 网络请求:https://github.com/zhou-you/RxEasyHttp
131
182
// RxJava: https://github.com/ReactiveX/RxAndroid
132
183
// RecyclerView:https://github.com/CymChad/BaseRecyclerViewAdapterHelper
184
+ // 上拉刷新下拉加载:https://github.com/scwang90/SmartRefreshLayout
133
185
// 工具类:https://github.com/Blankj/AndroidUtilCode
134
186
// 图片选择:https://github.com/zhihu/Matisse
135
- // 上拉下拉:https://github.com/bingoogolapple/BGARefreshLayout-Android
136
187
// 轮播图:https://github.com/bingoogolapple/BGABanner-Android
137
188
// 二维码:https://github.com/bingoogolapple/BGAQRCode-Android
138
189
// 第三方支付:https://github.com/getActivity/RxPay
139
190
// Log 打印:https://github.com/JakeWharton/timber
140
- }
141
-
142
- repositories {
143
- flatDir {
144
- dirs ' libs' // 就是你放aar的目录地址
145
- }
191
+ // 重要数据存储:https://github.com/Tencent/MMKV
146
192
}
0 commit comments