You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

474 lines
18 KiB

  1. apply plugin: 'com.android.application'
  2. def javaVersion = JavaVersion.VERSION_1_7
  3. android {
  4. compileSdkVersion 23
  5. buildToolsVersion "23.0.3"
  6. compileOptions {
  7. sourceCompatibility javaVersion
  8. targetCompatibility javaVersion
  9. }
  10. //recommend
  11. dexOptions {
  12. jumboMode = true
  13. }
  14. defaultConfig {
  15. multiDexEnabled true
  16. }
  17. signingConfigs {
  18. release {
  19. keyAlias 'aeo_android.keystore'
  20. keyPassword '025311'
  21. storeFile file('./keystore/mykeystore.keystore')
  22. storePassword '025311'
  23. }
  24. debug {
  25. keyAlias 'aeo_android.keystore'
  26. keyPassword '025311'
  27. storeFile file('./keystore/mykeystore.keystore')
  28. storePassword '025311'
  29. }
  30. }
  31. defaultConfig {
  32. // 正式版:com.zzcx.driver
  33. // 测试版:com.zzcx.driver2
  34. // 南京运游通:com.zzcx.driver.njyyt
  35. applicationId "com.zzcx.driver"
  36. minSdkVersion 18
  37. targetSdkVersion 23
  38. versionCode 5
  39. versionName "2.2.3"
  40. ndk {
  41. //选择要添加的对应cpu类型的.so库。
  42. abiFilters 'armeabi', 'armeabi-v7a', 'armeabi-v8a'
  43. // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
  44. }
  45. // 正式版:0fdf462e3c9d6ddaa525a4fd
  46. // 测试版:ce8e9d4efc50ed5dae529485
  47. // 南京运游通版:21728e82c1f15295eff75084
  48. manifestPlaceholders = [
  49. JPUSH_PKGNAME: applicationId,
  50. JPUSH_APPKEY : "0fdf462e3c9d6ddaa525a4fd", //JPush上注册的包名对应的appkey.
  51. JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
  52. ]
  53. /**
  54. * you can use multiDex and install it in your ApplicationLifeCycle implement
  55. */
  56. multiDexEnabled true
  57. /**
  58. * buildConfig can change during patch!
  59. * we can use the newly value when patch
  60. */
  61. buildConfigField "String", "MESSAGE", "\"I am the base apk\""
  62. // buildConfigField "String", "MESSAGE", "\"I am the patch apk\""
  63. /**
  64. * client version would update with patch
  65. * so we can get the newly git version easily!
  66. */
  67. buildConfigField "String", "TINKER_ID", "\"${getTinkerIdValue()}\""
  68. buildConfigField "String", "PLATFORM", "\"all\""
  69. }
  70. buildTypes {
  71. release {
  72. minifyEnabled true
  73. signingConfig signingConfigs.release
  74. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  75. }
  76. debug {
  77. debuggable true
  78. minifyEnabled false
  79. signingConfig signingConfigs.release
  80. }
  81. }
  82. task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") {
  83. destinationDir file("src/main/libs")
  84. baseName "Native_Libs2"
  85. extension "jar"
  86. from fileTree(dir: "src/main/libs", include: "**/*.so")
  87. into "lib"
  88. }
  89. tasks.withType(JavaCompile) {
  90. compileTask -> compileTask.dependsOn(nativeLibsToJar)
  91. }
  92. packagingOptions {
  93. exclude 'META-INF/DEPENDENCIES.txt'
  94. exclude 'META-INF/LICENSE.txt'
  95. exclude 'META-INF/NOTICE.txt'
  96. exclude 'META-INF/NOTICE'
  97. exclude 'META-INF/LICENSE'
  98. exclude 'META-INF/DEPENDENCIES'
  99. exclude 'META-INF/notice.txt'
  100. exclude 'META-INF/license.txt'
  101. exclude 'META-INF/dependencies.txt'
  102. exclude 'META-INF/LGPL2.1'
  103. }
  104. sourceSets {
  105. main {
  106. jniLibs.srcDir(['libs'])
  107. }
  108. }
  109. }
  110. repositories {
  111. maven {
  112. url "https://jitpack.io"
  113. }
  114. }
  115. def bakPath = file("${buildDir}/bakApk/")
  116. /**
  117. * you can use assembleRelease to build you base apk
  118. * use tinkerPatchRelease -POLD_APK= -PAPPLY_MAPPING= -PAPPLY_RESOURCE= to build patch
  119. * add apk from the build/bakApk
  120. */
  121. ext {
  122. //for some reason, you may want to ignore tinkerBuild, such as instant run debug build?
  123. tinkerEnabled = true
  124. //for normal build
  125. //old apk file to build patch apk
  126. tinkerOldApkPath = "${bakPath}/app-debug-0407-19-00-16.apk"
  127. //proguard mapping file to build patch apk
  128. tinkerApplyMappingPath = "${bakPath}/app-debug-0308-14-24-36-mapping.txt"
  129. //resource R.txt to build patch apk, must input if there is resource changed
  130. tinkerApplyResourcePath = "${bakPath}/app-debug-0308-14-24-36-R.txt"
  131. //only use for build all flavor, if not, just ignore this field
  132. tinkerBuildFlavorDirectory = "${bakPath}/app-1018-17-32-47"
  133. }
  134. def getOldApkPath() {
  135. return hasProperty("OLD_APK") ? OLD_APK : ext.tinkerOldApkPath
  136. }
  137. def getApplyMappingPath() {
  138. return hasProperty("APPLY_MAPPING") ? APPLY_MAPPING : ext.tinkerApplyMappingPath
  139. }
  140. def getApplyResourceMappingPath() {
  141. return hasProperty("APPLY_RESOURCE") ? APPLY_RESOURCE : ext.tinkerApplyResourcePath
  142. }
  143. def getTinkerIdValue() {
  144. //return hasProperty("TINKER_ID") ? TINKER_ID : gitSha()
  145. return "tickerId";
  146. }
  147. def buildWithTinker() {
  148. return hasProperty("TINKER_ENABLE") ? TINKER_ENABLE : ext.tinkerEnabled
  149. }
  150. def getTinkerBuildFlavorDirectory() {
  151. return ext.tinkerBuildFlavorDirectory
  152. }
  153. if (buildWithTinker()) {
  154. apply plugin: 'com.tencent.tinker.patch'
  155. tinkerPatch {
  156. /**
  157. * necessary,default 'null'
  158. * the old apk path, use to diff with the new apk to build
  159. * add apk from the build/bakApk
  160. */
  161. oldApk = getOldApkPath()
  162. /**
  163. * optional,default 'false'
  164. * there are some cases we may get some warnings
  165. * if ignoreWarning is true, we would just assert the patch process
  166. * case 1: minSdkVersion is below 14, but you are using dexMode with raw.
  167. * it must be crash when load.
  168. * case 2: newly added Android Component in AndroidManifest.xml,
  169. * it must be crash when load.
  170. * case 3: loader classes in dex.loader{} are not keep in the main dex,
  171. * it must be let tinker not work.
  172. * case 4: loader classes in dex.loader{} changes,
  173. * loader classes is ues to load patch dex. it is useless to change them.
  174. * it won't crash, but these changes can't effect. you may ignore it
  175. * case 5: resources.arsc has changed, but we don't use applyResourceMapping to build
  176. */
  177. ignoreWarning = true
  178. /**
  179. * optional,default 'true'
  180. * whether sign the patch file
  181. * if not, you must do yourself. otherwise it can't check success during the patch loading
  182. * we will use the sign config with your build type
  183. */
  184. useSign = true
  185. /**
  186. * optional,default 'true'
  187. * whether use tinker to build
  188. */
  189. tinkerEnable = buildWithTinker()
  190. /**
  191. * Warning, applyMapping will affect the normal android build!
  192. */
  193. buildConfig {
  194. /**
  195. * optional,default 'null'
  196. * if we use tinkerPatch to build the patch apk, you'd better to apply the old
  197. * apk mapping file if minifyEnabled is enable!
  198. * Warning:
  199. * you must be careful that it will affect the normal assemble build!
  200. */
  201. applyMapping = getApplyMappingPath()
  202. /**
  203. * optional,default 'null'
  204. * It is nice to keep the resource id from R.txt file to reduce java changes
  205. */
  206. applyResourceMapping = getApplyResourceMappingPath()
  207. /**
  208. * necessary,default 'null'
  209. * because we don't want to check the base apk with md5 in the runtime(it is slow)
  210. * tinkerId is use to identify the unique base apk when the patch is tried to apply.
  211. * we can use git rev, svn rev or simply versionCode.
  212. * we will gen the tinkerId in your manifest automatic
  213. */
  214. tinkerId = "tinkerId"
  215. /**
  216. * if keepDexApply is true, class in which dex refer to the old apk.
  217. * open this can reduce the dex diff file size.
  218. */
  219. keepDexApply = false
  220. }
  221. dex {
  222. /**
  223. * optional,default 'jar'
  224. * only can be 'raw' or 'jar'. for raw, we would keep its original format
  225. * for jar, we would repack dexes with zip format.
  226. * if you want to support below 14, you must use jar
  227. * or you want to save rom or check quicker, you can use raw mode also
  228. */
  229. dexMode = "jar"
  230. /**
  231. * necessary,default '[]'
  232. * what dexes in apk are expected to deal with tinkerPatch
  233. * it support * or ? pattern.
  234. */
  235. pattern = ["classes*.dex",
  236. "assets/secondary-dex-?.jar"]
  237. /**
  238. * necessary,default '[]'
  239. * Warning, it is very very important, loader classes can't change with patch.
  240. * thus, they will be removed from patch dexes.
  241. * you must put the following class into main dex.
  242. * Simply, you should add your own application {@code tinker.sample.android.SampleApplication}
  243. * own tinkerLoader, and the classes you use in them
  244. *
  245. */
  246. loader = [
  247. //use sample, let BaseBuildInfo unchangeable with tinker
  248. "com.zzcx.driver.tinker.BaseBuildInfo"
  249. ]
  250. }
  251. lib {
  252. /**
  253. * optional,default '[]'
  254. * what library in apk are expected to deal with tinkerPatch
  255. * it support * or ? pattern.
  256. * for library in assets, we would just recover them in the patch directory
  257. * you can get them in TinkerLoadResult with Tinker
  258. */
  259. pattern = ["lib/*/*.so"]
  260. }
  261. res {
  262. /**
  263. * optional,default '[]'
  264. * what resource in apk are expected to deal with tinkerPatch
  265. * it support * or ? pattern.
  266. * you must include all your resources in apk here,
  267. * otherwise, they won't repack in the new apk resources.
  268. */
  269. pattern = ["res/*", "assets/*", "resources.arsc", "AndroidManifest.xml"]
  270. /**
  271. * optional,default '[]'
  272. * the resource file exclude patterns, ignore add, delete or modify resource change
  273. * it support * or ? pattern.
  274. * Warning, we can only use for files no relative with resources.arsc
  275. */
  276. ignoreChange = ["assets/sample_meta.txt"]
  277. /**
  278. * default 100kb
  279. * for modify resource, if it is larger than 'largeModSize'
  280. * we would like to use bsdiff algorithm to reduce patch file size
  281. */
  282. largeModSize = 100
  283. }
  284. packageConfig {
  285. /**
  286. * optional,default 'TINKER_ID, TINKER_ID_VALUE' 'NEW_TINKER_ID, NEW_TINKER_ID_VALUE'
  287. * package meta file gen. path is assets/package_meta.txt in patch file
  288. * you can use securityCheck.getPackageProperties() in your ownPackageCheck method
  289. * or TinkerLoadResult.getPackageConfigByName
  290. * we will get the TINKER_ID from the old apk manifest for you automatic,
  291. * other config files (such as patchMessage below)is not necessary
  292. */
  293. configField("patchMessage", "tinker is sample to use")
  294. /**
  295. * just a sample case, you can use such as sdkVersion, brand, channel...
  296. * you can parse it in the SamplePatchListener.
  297. * Then you can use patch conditional!
  298. */
  299. configField("platform", "all")
  300. /**
  301. * patch version via packageConfig
  302. */
  303. configField("patchVersion", "1.0")
  304. }
  305. //or you can add config filed outside, or get meta value from old apk
  306. //project.tinkerPatch.packageConfig.configField("test1", project.tinkerPatch.packageConfig.getMetaDataFromOldApk("Test"))
  307. //project.tinkerPatch.packageConfig.configField("test2", "sample")
  308. /**
  309. * if you don't use zipArtifact or path, we just use 7za to try
  310. */
  311. sevenZip {
  312. /**
  313. * optional,default '7za'
  314. * the 7zip artifact path, it will use the right 7za with your platform
  315. */
  316. zipArtifact = "com.tencent.mm:SevenZip:1.1.10"
  317. /**
  318. * optional,default '7za'
  319. * you can specify the 7za path yourself, it will overwrite the zipArtifact value
  320. */
  321. // path = "/usr/local/bin/7za"
  322. }
  323. }
  324. List<String> flavors = new ArrayList<>();
  325. project.android.productFlavors.each {flavor ->
  326. flavors.add(flavor.name)
  327. }
  328. boolean hasFlavors = flavors.size() > 0
  329. /**
  330. * bak apk and mapping
  331. */
  332. android.applicationVariants.all { variant ->
  333. /**
  334. * task type, you want to bak
  335. */
  336. def taskName = variant.name
  337. def date = new Date().format("MMdd-HH-mm-ss")
  338. tasks.all {
  339. if ("assemble${taskName.capitalize()}".equalsIgnoreCase(it.name)) {
  340. it.doLast {
  341. copy {
  342. def fileNamePrefix = "${project.name}-${variant.baseName}"
  343. def newFileNamePrefix = hasFlavors ? "${fileNamePrefix}" : "${fileNamePrefix}-${date}"
  344. def destPath = hasFlavors ? file("${bakPath}/${project.name}-${date}/${variant.flavorName}") : bakPath
  345. from variant.outputs.outputFile
  346. into destPath
  347. rename { String fileName ->
  348. fileName.replace("${fileNamePrefix}.apk", "${newFileNamePrefix}.apk")
  349. }
  350. from "${buildDir}/outputs/mapping/${variant.dirName}/mapping.txt"
  351. into destPath
  352. rename { String fileName ->
  353. fileName.replace("mapping.txt", "${newFileNamePrefix}-mapping.txt")
  354. }
  355. from "${buildDir}/intermediates/symbols/${variant.dirName}/R.txt"
  356. into destPath
  357. rename { String fileName ->
  358. fileName.replace("R.txt", "${newFileNamePrefix}-R.txt")
  359. }
  360. }
  361. }
  362. }
  363. }
  364. }
  365. project.afterEvaluate {
  366. //sample use for build all flavor for one time
  367. if (hasFlavors) {
  368. task(tinkerPatchAllFlavorRelease) {
  369. group = 'tinker'
  370. def originOldPath = getTinkerBuildFlavorDirectory()
  371. for (String flavor : flavors) {
  372. def tinkerTask = tasks.getByName("tinkerPatch${flavor.capitalize()}Release")
  373. dependsOn tinkerTask
  374. def preAssembleTask = tasks.getByName("process${flavor.capitalize()}ReleaseManifest")
  375. preAssembleTask.doFirst {
  376. String flavorName = preAssembleTask.name.substring(7, 8).toLowerCase() + preAssembleTask.name.substring(8, preAssembleTask.name.length() - 15)
  377. project.tinkerPatch.oldApk = "${originOldPath}/${flavorName}/${project.name}-${flavorName}-release.apk"
  378. project.tinkerPatch.buildConfig.applyMapping = "${originOldPath}/${flavorName}/${project.name}-${flavorName}-release-mapping.txt"
  379. project.tinkerPatch.buildConfig.applyResourceMapping = "${originOldPath}/${flavorName}/${project.name}-${flavorName}-release-R.txt"
  380. }
  381. }
  382. }
  383. task(tinkerPatchAllFlavorDebug) {
  384. group = 'tinker'
  385. def originOldPath = getTinkerBuildFlavorDirectory()
  386. for (String flavor : flavors) {
  387. def tinkerTask = tasks.getByName("tinkerPatch${flavor.capitalize()}Debug")
  388. dependsOn tinkerTask
  389. def preAssembleTask = tasks.getByName("process${flavor.capitalize()}DebugManifest")
  390. preAssembleTask.doFirst {
  391. String flavorName = preAssembleTask.name.substring(7, 8).toLowerCase() + preAssembleTask.name.substring(8, preAssembleTask.name.length() - 13)
  392. project.tinkerPatch.oldApk = "${originOldPath}/${flavorName}/${project.name}-${flavorName}-debug.apk"
  393. project.tinkerPatch.buildConfig.applyMapping = "${originOldPath}/${flavorName}/${project.name}-${flavorName}-debug-mapping.txt"
  394. project.tinkerPatch.buildConfig.applyResourceMapping = "${originOldPath}/${flavorName}/${project.name}-${flavorName}-debug-R.txt"
  395. }
  396. }
  397. }
  398. }
  399. }
  400. }
  401. dependencies {
  402. compile fileTree(include: ['*.jar'], dir: 'src/main/libs')
  403. //compile fileTree(include: ['*.jar'], dir: 'libs')
  404. testCompile 'junit:junit:4.12'
  405. //日期选择控件
  406. compile project(':library:WheelPicker')
  407. // 极光推送,此处以SDK 2.1.8版本为例
  408. compile files('src/main/jniLibs/AMap3DMap_4.1.3_AMapNavi_1.9.4_AMapSearch_3.6.1_AMapLocation_3.2.0_20161208.jar')
  409. compile 'com.google.android.gms:play-services-appindexing:8.1.0'
  410. compile 'com.android.support:appcompat-v7:23.4.0'
  411. compile 'com.android.support:design:23.4.0'
  412. compile 'com.github.bumptech.glide:glide:3.6.0'
  413. compile 'de.hdodenhof:circleimageview:1.3.0'
  414. compile 'com.github.jalasoft:HttpClient:1.0.5'
  415. compile 'cn.jiguang:jpush:2.1.8'
  416. compile 'com.alibaba:fastjson:1.2.20'
  417. compile 'com.github.hackware1993:MagicIndicator:1.5.0'
  418. compile 'com.android.support:support-v4:23.4.0'
  419. compile 'com.android.support:recyclerview-v7:23.4.0'
  420. compile 'com.android.support:cardview-v7:23.4.0'
  421. compile project(':circleprogressbar')
  422. compile 'com.github.dmytrodanylyk.shadow-layout:library:1.0.3'
  423. compile 'com.chanven.lib:cptr:1.1.0'
  424. //以下是友盟crash监测
  425. compile 'com.umeng.analytics:analytics:latest.integration'
  426. //以下是tinker热修复
  427. compile("com.tencent.tinker:tinker-android-lib:${TINKER_VERSION}") { changing = true }
  428. provided("com.tencent.tinker:tinker-android-anno:${TINKER_VERSION}") { changing = true }
  429. compile 'com.android.support:multidex:1.0.1'
  430. }