@@ -3,6 +3,13 @@ apply plugin: 'com.android.application'
33android {
44 compileSdkVersion rootProject. ext. compileSdkVersion
55 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+
613 defaultConfig {
714 // 无痛修改包名:https://www.jianshu.com/p/17327e191d2e
815 applicationId " com.hjq.demo"
@@ -11,6 +18,16 @@ android {
1118 versionCode 10
1219 versionName " 1.0"
1320 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+ }
1431 }
1532
1633 // APK 签名的那些事:https://www.jianshu.com/p/a1f8e5896aa2
@@ -39,33 +56,29 @@ android {
3956 zipAlignEnabled true
4057 // 设置混淆
4158 minifyEnabled true
42- // 加载默认混淆配置涵
43- proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
4459 // 正式环境签名
4560 // signingConfig signingConfigs.release
4661 }
4762
4863 debug {
49- // ZipAlign优化
64+ // ZipAlign优化
5065 zipAlignEnabled false
51- // 设置混淆
66+ // 设置混淆
5267 minifyEnabled false
53- // 加载默认混淆配置涵
54- proguardFiles getDefaultProguardFile(' proguard-android.txt' ), ' proguard-rules.pro'
5568 // 开发环境签名
5669 // signingConfig signingConfigs.debug
5770 }
5871 }
5972
60- flavorDimensions " default" // 这个名字貌似随便取,也可以有多个,总之一定要有
61- // 多渠道打包
73+ flavorDimensions " default" // 这个名字貌似随便取,也可以有多个,总之一定要有
74+ // 友盟多渠道打包
6275 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 {} // 谷歌
6982
7083 productFlavors. all { flavor ->
7184 flavor. manifestPlaceholders = [UMENG_CHANNEL_VALUE : name]
@@ -78,69 +91,102 @@ android {
7891 jniLibs. srcDirs = [' libs' ]
7992 }
8093 }
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+ }
81122}
82123
83- // api 与 implementation的区别 :https://www.jianshu.com/p/8962d6ba936e
124+ // api 与 implementation 的区别 :https://www.jianshu.com/p/8962d6ba936e
84125dependencies {
85- // 依赖 libs 目录下所有 Jar 包
126+ // 依赖 libs 目录下所有 jar 包
86127 implementation fileTree(include : [' *.jar' ], dir : ' libs' )
128+ // 依赖 libs 目录下所有 aar 包
129+ implementation fileTree(include : [' *.aar' ], dir : ' libs' )
130+
87131 // 基础库(不包任何第三方框架)
88132 implementation project(' :base' )
89133 // 自定义 View
90134 implementation project(' :widget' )
91- // 图片加载封装
135+ // Dialog 封装
136+ implementation project(' :dialog' )
137+ // Glide 隔离
92138 implementation project(' :image' )
93- // 友盟
139+ // 友盟隔离
94140 implementation project(' :umeng' )
95- // Dialog
96- implementation project(' :dialog' )
97-
98- // 示例:添加一个 aar 包
99- // implementation(name: 'library', ext: 'aar')
100141
101142 implementation " com.android.support:appcompat-v7:$rootProject . ext . supportLibraryVersion "
102143 implementation " com.android.support:design:$rootProject . ext . supportLibraryVersion "
103144 implementation " com.android.support:support-v4:$rootProject . ext . supportLibraryVersion "
104145 implementation " com.android.support:cardview-v7:$rootProject . ext . supportLibraryVersion "
105146 implementation " com.android.support.constraint:constraint-layout:$rootProject . ext . constraintLayoutVersion "
106147
107- // Dex分包,解决 65k 问题
148+ // Dex分包,解决 64k 问题
108149 implementation ' com.android.support:multidex:1.0.3'
109150
110- // ButterKnife注解库 :https://github.com/JakeWharton/butterknife
151+ // ButterKnife 注解库 :https://github.com/JakeWharton/butterknife
111152 implementation ' com.jakewharton:butterknife:9.0.0-rc1'
112153 annotationProcessor ' com.jakewharton:butterknife-compiler:9.0.0-rc1'
113154
155+ // EventBus 事件总线
156+ implementation " org.greenrobot:eventbus:3.1.1"
157+ annotationProcessor ' org.greenrobot:eventbus-annotation-processor:3.1.1'
158+
114159 // 状态栏沉浸:https://github.com/gyf-dev/ImmersionBar
115160 implementation ' com.gyf.immersionbar:immersionbar:2.3.3'
116161 // 侧滑功能:https://github.com/bingoogolapple/BGASwipeBackLayout-Android
117162 implementation ' cn.bingoogolapple:bga-swipebacklayout:1.2.0'
118163
119164 // 权限请求框架:https://github.com/getActivity/XXPermissions
120- implementation ' com.hjq:xxpermissions:latest.integration '
165+ implementation ' com.hjq:xxpermissions:5.5 '
121166 // 标题栏:https://github.com/getActivity/TitleBar
122- implementation ' com.hjq:titlebar:latest.integration '
167+ implementation ' com.hjq:titlebar:5.0 '
123168 // 吐司工具类:https://github.com/getActivity/ToastUtils
124- implementation ' com.hjq:toast:latest.integration '
169+ implementation ' com.hjq:toast:6.0 '
125170
126171 // 圆形的ImageView:https://github.com/hdodenhof/CircleImageView
127172 implementation ' de.hdodenhof:circleimageview:2.2.0'
128173
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
129180 // 悬浮窗:https://github.com/getActivity/XToast
130181 // 网络请求:https://github.com/zhou-you/RxEasyHttp
131182 // RxJava: https://github.com/ReactiveX/RxAndroid
132183 // RecyclerView:https://github.com/CymChad/BaseRecyclerViewAdapterHelper
184+ // 上拉刷新下拉加载:https://github.com/scwang90/SmartRefreshLayout
133185 // 工具类:https://github.com/Blankj/AndroidUtilCode
134186 // 图片选择:https://github.com/zhihu/Matisse
135- // 上拉下拉:https://github.com/bingoogolapple/BGARefreshLayout-Android
136187 // 轮播图:https://github.com/bingoogolapple/BGABanner-Android
137188 // 二维码:https://github.com/bingoogolapple/BGAQRCode-Android
138189 // 第三方支付:https://github.com/getActivity/RxPay
139190 // Log 打印:https://github.com/JakeWharton/timber
140- }
141-
142- repositories {
143- flatDir {
144- dirs ' libs' // 就是你放aar的目录地址
145- }
191+ // 重要数据存储:https://github.com/Tencent/MMKV
146192}
0 commit comments