apply plugin: 'com.android.application' static String getBuildConfigFieldValue(def variant, def fiedName) { def properties = variant.productFlavors[0].properties def name = properties.get("name") if (name != variant.flavorName) { return "" } def configs = properties.get("buildConfigFields") def address = null for (Map.Entry item : configs) { def key = item.key if (key == fiedName) { address = item.value } } if (address == null) return "" def field = address.getClass().getDeclaredField("value") field.setAccessible(true) return field.get(address).toString().replace("\"", "") } static def releaseTime() { return new Date().format("yyyyMMdd_HHmmss", TimeZone.getDefault()) } android { compileSdkVersion 29 buildToolsVersion "29.0.3" defaultConfig { minSdkVersion 24 targetSdkVersion 29 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true ndk { //选择要添加的对应 cpu 类型的 .so 库。 abiFilters 'armeabi-v7a', 'arm64-v8a', "x86" // 还可以添加 'armeabi', 'x86', 'x86_64', 'mips', 'mips64' } } lintOptions { checkReleaseBuilds false // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError false } dexOptions { jumboMode true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } //多版本 productFlavors { kuxin { flavorDimensions "default" applicationId "com.uiuipad.find" versionCode 27 versionName "1.2.6" buildConfigField "String", "app_name", '"小酷守护"' manifestPlaceholders = [ ALIPUSH_KEY : "333898263", ALIPUSH_SECRET: "e1b374229ffe479eb34ba74432b7e454", ] } aiKuxin { flavorDimensions "default" applicationId "com.aole.safe" versionCode 1 versionName "1.0.0" buildConfigField "String", "app_name", '"守护中心"' manifestPlaceholders = [ ALIPUSH_KEY : "333982424", ALIPUSH_SECRET: "c831992e2de743dcad66f5ec420798a4", ] } aigo { flavorDimensions "default" applicationId "com.safeos.ae" versionCode 1 versionName "1.0.0" buildConfigField "String", "app_name", '"安全守护"' manifestPlaceholders = [ ALIPUSH_KEY : "333982410", ALIPUSH_SECRET: "6d8785a73d904055ac00f84d83400be4", ] } phone { flavorDimensions "default" applicationId "com.dangsafe.kf" versionCode 1 versionName "1.0.0" buildConfigField "String", "app_name", '"时间守护"' manifestPlaceholders = [ ALIPUSH_KEY : "333982833", ALIPUSH_SECRET: "67a5bf10515947459c04fc000367feca", ] } } //签名 signingConfigs { //iPlay50 mini,iPlay50 android13 共用签名 iPlay50mini { storeFile file("keystore/iPlay50Mini.keystore") storePassword "android" keyAlias "platform" keyPassword "android" v2SigningEnabled false } iPlay50SE { storeFile file("keystore/iPlay50SE.keystore") storePassword "123456" keyAlias "iplay50se" keyPassword "123456" v1SigningEnabled true v2SigningEnabled true } U807 { storeFile file("keystore/AllwinnerU807.jks") storePassword "123456" keyAlias "u807" keyPassword "123456" v2SigningEnabled false } U807UserDebug { storeFile file("keystore/U807userdebug.keystore") storePassword "123456" keyAlias "u807userdebug" keyPassword "123456" v2SigningEnabled false } G10P { storeFile file("keystore/G10PMTK11.jks") storePassword "123456" keyAlias "G10PMTK11" keyPassword "123456" v1SigningEnabled true v2SigningEnabled true } teclast8183 { storeFile file("keystore/TeclastMTK12.jks") storePassword "123456" keyAlias "TeclastMTK12" keyPassword "123456" v2SigningEnabled false } UnisocS6688 { storeFile file("keystore/UnisocS6688Userdebug.jks") storePassword "123456" keyAlias "unisocs6688userdebug" keyPassword "123456" v1SigningEnabled true v2SigningEnabled true } Aigo1071 { storeFile file("keystore/Aigo1071.jks") storePassword "123456" keyAlias "aigo1071" keyPassword "123456" v1SigningEnabled true v2SigningEnabled true } } buildTypes { Aigo1071Debug.initWith(debug) Aigo1071Debug { versionNameSuffix "-debug" debuggable true signingConfig signingConfigs.Aigo1071 buildConfigField "String", "platform", '"W8183"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] } Aigo1071Release.initWith(release) Aigo1071Release { signingConfig signingConfigs.Aigo1071 buildConfigField "String", "platform", '"W8183"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] } UnisocS6688Debug.initWith(debug) UnisocS6688Debug { versionNameSuffix "-debug" debuggable true signingConfig signingConfigs.UnisocS6688 buildConfigField "String", "platform", '"S6688"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] } UnisocS6688Release.initWith(release) UnisocS6688Release { signingConfig signingConfigs.UnisocS6688 buildConfigField "String", "platform", '"S6688"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] } teclast8183Debug.initWith(debug) teclast8183Debug { versionNameSuffix "-debug" debuggable true signingConfig signingConfigs.teclast8183 buildConfigField "String", "platform", '"A11MTK8183"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] } teclast8183Release.initWith(release) teclast8183Release { signingConfig signingConfigs.teclast8183 buildConfigField "String", "platform", '"A11MTK8183"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] } G10PDebug.initWith(debug) G10PDebug { versionNameSuffix "-debug" debuggable true signingConfig signingConfigs.G10P buildConfigField "String", "platform", '"G10P"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] } G10PRelease.initWith(release) G10PRelease { signingConfig signingConfigs.G10P buildConfigField "String", "platform", '"G10P"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] } U807UserDebug.initWith(release) U807UserDebug { // versionNameSuffix "-debug" // debuggable true signingConfig signingConfigs.U807UserDebug buildConfigField "String", "platform", '"U807"' manifestPlaceholders = [ Baidu_AK: "yhlCxeBmZ1I7ZO50Emw4ptPtcYGOFg59" ] } U807Debug.initWith(debug) U807Debug { versionNameSuffix "-debug" debuggable true signingConfig signingConfigs.U807 buildConfigField "String", "platform", '"U807"' manifestPlaceholders = [ Baidu_AK: "yhlCxeBmZ1I7ZO50Emw4ptPtcYGOFg59" ] } U807Release.initWith(release) U807Release { signingConfig signingConfigs.U807 buildConfigField "String", "platform", '"U807"' manifestPlaceholders = [ Baidu_AK: "yhlCxeBmZ1I7ZO50Emw4ptPtcYGOFg59" ] } iPlay50SEDebug.initWith(debug) iPlay50SEDebug { versionNameSuffix "-debug" debuggable true signingConfig signingConfigs.iPlay50SE buildConfigField "String", "platform", '"MTK8183"' manifestPlaceholders = [ Baidu_AK: "yhlCxeBmZ1I7ZO50Emw4ptPtcYGOFg59" ] } iPlay50SERelease.initWith(release) iPlay50SERelease { signingConfig signingConfigs.iPlay50SE buildConfigField "String", "platform", '"MTK8183"' manifestPlaceholders = [ Baidu_AK: "yhlCxeBmZ1I7ZO50Emw4ptPtcYGOFg59" ] } debug { versionNameSuffix "-debug" debuggable true //Zipalign优化 zipAlignEnabled true minifyEnabled false signingConfig signingConfigs.iPlay50mini buildConfigField "String", "platform", '"iPlay50mini"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] applicationVariants.all { variant -> variant.outputs.each { output -> if (outputFile != null) { def fileName = "${getBuildConfigFieldValue(variant, "app_name")}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk" output.outputFileName = fileName } } } } release { //Zipalign优化 zipAlignEnabled true //混淆 minifyEnabled false //前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' //签名 signingConfig signingConfigs.iPlay50mini buildConfigField "String", "platform", '"iPlay50mini"' manifestPlaceholders = [ Baidu_AK: "YCmfZSw54O992lChzS3c4roYioitT54h" ] // 将release版本的包名重命名,加上版本及日期 applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = "" if (outputFile != null) { def fileName = "${getBuildConfigFieldValue(variant, "app_name")}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk" output.outputFileName = new File(outputFile, fileName) } } } } } sourceSets { kuxin { res { srcDirs 'src/res' } } aiKuxin { res { srcDirs 'src/aiKuxin/res' } } aigo { res { srcDirs 'src/aigo/res' } } phone { res { srcDirs 'src/phone/res' } } } externalNativeBuild { cmake { path file('CMakeLists.txt') } } } dependencies { // implementation fileTree(dir: 'libs', include: ['*.jar']) compileOnly files('libs/framework.jar') implementation project(path: ':niceimageview') implementation project(path: ':verification-view') implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' //BindView implementation 'com.jakewharton:butterknife:10.2.3' // If you are using Kotlin, replace annotationProcessor with kapt. // annotationProcessor rootProject.ext.dependencies["butterknife-compiler"] annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' //okhttp implementation 'com.squareup.okhttp3:okhttp:4.9.0' //Retrofit implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0' // gson converter implementation 'com.squareup.retrofit2:converter-gson:2.9.0' // 标准转换器,去掉 Retrofit以Mutipart上传参数时,String参数会多一对双引号 implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' //RxJava implementation 'io.reactivex.rxjava3:rxjava:3.0.0' implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' //生命周期管理 implementation 'com.trello.rxlifecycle4:rxlifecycle:4.0.2' implementation 'com.trello.rxlifecycle4:rxlifecycle-android:4.0.2' implementation 'com.trello.rxlifecycle4:rxlifecycle-components:4.0.2' implementation 'com.trello.rxlifecycle4:rxlifecycle-components-preference:4.0.2' implementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle:4.0.2' //Google implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.google.zxing:core:3.5.0' //图片加载框架 implementation 'com.github.bumptech.glide:glide:4.15.1' annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1' //MMKV implementation 'com.tencent:mmkv-static:1.2.14' //阿里云推送 implementation 'com.aliyun.ams:alicloud-android-push:3.8.0' //百度地图 implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8' //工具类 implementation 'com.blankj:utilcodex:1.31.0' //沉浸状态栏 implementation 'com.gitee.zackratos:UltimateBarX:0.8.0' implementation 'com.jakewharton.rxbinding2:rxbinding:2.2.0' //Aria implementation 'com.arialyy.aria:core:3.8.15' annotationProcessor 'com.arialyy.aria:compiler:3.8.15' //Java WebSocket implementation "org.java-websocket:Java-WebSocket:1.5.3" implementation 'com.tencent.bugly:crashreport:4.1.9.2' implementation 'com.iqiyi.xcrash:xcrash-android-lib:3.0.0' } preBuild { doLast { def imlFile = file(project.name + ".iml") println 'Change ' + project.name + '.iml order' try { def parsedXml = (new XmlParser()).parse(imlFile) def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' } parsedXml.component[1].remove(jdkNode) def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform" println 'what' + sdkString new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) } catch (FileNotFoundException e) { // nop, iml not found println "no iml found" } } //https://www.pianshen.com/article/93481144911/ //使用系统编译后的framework.jar }