From a154f480f62a23aee4323cdadcf69d2c57104722 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 20 Jun 2024 14:02:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E9=85=8D=E7=BD=AE=E5=8C=96?= =?UTF-8?q?=E6=89=93=E5=8C=85=E7=A8=8B=E5=BA=8F=EF=BC=8C=E5=8F=AF=E6=9C=89?= =?UTF-8?q?=E6=95=88=E9=98=B2=E6=AD=A2=E6=89=8B=E5=8A=A8=E6=89=93=E5=8C=85?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FaceUnity/build.gradle | 2 +- IAP6Helper/build.gradle | 2 + Share/build.gradle | 2 +- app/build.gradle | 143 +++++++++++++++++-------------- app/src/main/AndroidManifest.xml | 1 + build.gradle | 6 +- common/build.gradle | 19 ++-- config.gradle | 6 +- lib_country_code/build.gradle | 2 +- lib_faceunity/build.gradle | 4 +- lib_google/build.gradle | 1 + lib_huawei/build.gradle | 1 + live/build.gradle | 2 +- main/build.gradle | 1 + package_config.gradle | 78 +++++++++++++++++ settings.gradle | 2 +- video/build.gradle | 2 +- 17 files changed, 188 insertions(+), 86 deletions(-) create mode 100644 package_config.gradle diff --git a/FaceUnity/build.gradle b/FaceUnity/build.gradle index 99cc08f51..6a51680ba 100644 --- a/FaceUnity/build.gradle +++ b/FaceUnity/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' apply plugin: 'kotlin-parcelize' - +apply from: "../package_config.gradle" android { compileSdkVersion rootProject.ext.android.compileSdkVersion diff --git a/IAP6Helper/build.gradle b/IAP6Helper/build.gradle index d8fc4749a..ba734c03e 100644 --- a/IAP6Helper/build.gradle +++ b/IAP6Helper/build.gradle @@ -1,4 +1,6 @@ apply plugin: 'com.android.library' +apply from: "../package_config.gradle" + android { compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion diff --git a/Share/build.gradle b/Share/build.gradle index d312a0a6e..3bde860d5 100644 --- a/Share/build.gradle +++ b/Share/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' apply plugin: 'kotlin-parcelize' - +apply from: "../package_config.gradle" android { compileSdkVersion rootProject.ext.android.compileSdkVersion diff --git a/app/build.gradle b/app/build.gradle index 3c5940adb..d7065ed3b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'img-optimizer' apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' apply plugin: 'com.alibaba.arouter' +apply from: "../package_config.gradle" android { dexOptions { jumboMode = true @@ -10,49 +11,6 @@ android { project.tasks.getByName("tasks").doFirst { } - /* flavorDimensions "packageApk" - productFlavors { - LinkTest { - dimension "packageApk" - manifestPlaceholders = [serverHost: "https://ceshi.yaoulive.com",isGooglePlay:0,isPluginModel:true] - } - LinkOfficial { - dimension "packageApk" - manifestPlaceholders = [serverHost: "https://napi.yaoulive.com",isGooglePlay:0,isPluginModel:true] - } - GoogleTest { - dimension "packageApk" - manifestPlaceholders = [serverHost: "https://ceshi.yaoulive.com",isGooglePlay:1,isPluginModel:false] - } - GoogleOfficial{ - dimension "packageApk" - manifestPlaceholders = [serverHost: "https://napi.yaoulive.com",isGooglePlay:1,isPluginModel:false] - } - - }*/ - /* applicationVariants.all { variant -> - variant.mergeAssetsProvider.configure { - doLast { - delete(fileTree(dir: outputDir, includes: [ - 'model/ai_bgseg_green.bundle', - 'model/ai_face_processor.bundle', - 'model/ai_face_processor_lite.bundle', - 'model/ai_hairseg.bundle', - 'model/ai_hand_processor.bundle', - 'model/ai_human_processor.bundle', - 'model/ai_human_processor_gpu.bundle', - 'model/ai_human_processor_mb_fast.bundle', - 'graphics/body_slim.bundle', - 'graphics/controller_cpp.bundle', - 'graphics/face_beautification.bundle', - 'graphics/face_makeup.bundle', - 'graphics/fuzzytoonfilter.bundle', - 'graphics/fxaa.bundle', - 'graphics/tongue.bundle' - ])) - } - } - }*/ compileSdkVersion rootProject.ext.android.compileSdkVersion buildToolsVersion rootProject.ext.android.buildToolsVersion @@ -128,22 +86,26 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + applicationVariants.all { variant -> println "清空build文件夹"; for (final def project in rootProject.getAllprojects()) { + def name = variant.name.replace('Debug', '').replace('Release', '').toLowerCase() delete project.buildDir + delete 'app' + File.separator + name println project.buildDir } String variantName = variant.name.capitalize() def processManifestTask = project.tasks.getByName("process${variantName}Manifest") processManifestTask.doLast { pm -> - String manifestPath = "build/intermediates/bundle_manifest/release/bundle-manifest/AndroidManifest.xml" - def isGooglePlay = rootProject.ext.manifestPlaceholders.isGooglePlay + String manifestPath = "build/intermediates/bundle_manifest/google_onlineRelease/bundle-manifest/AndroidManifest.xml" + def isGooglePlay = variant.name.contains("google") println "谷歌版本:" + isGooglePlay println "文件存在" + file(manifestPath).exists() println "" + (isGooglePlay != 0) - println "" + (file(manifestPath).exists() && isGooglePlay != 0) - if (file(manifestPath).exists() && isGooglePlay != 0) { + println "" + (file(manifestPath).exists() && isGooglePlay) + if (file(manifestPath).exists() && isGooglePlay) { def manifestContent = file(manifestPath).getText() println "移除权限" manifestContent = manifestContent.replace('', '') @@ -152,8 +114,8 @@ android { } else { print "not Exists = " + manifestPath } - manifestPath = "build/intermediates/merged_manifests/release/processReleaseManifest/AndroidManifest.xml" - if (file(manifestPath).exists() && isGooglePlay != 0) { + manifestPath = "build/intermediates/merged_manifests/google_onlineRelease/processReleaseManifest/AndroidManifest.xml" + if (file(manifestPath).exists() && isGooglePlay) { def manifestContent = file(manifestPath).getText() println "移除权限2" manifestContent = manifestContent.replace('', '') @@ -198,24 +160,75 @@ android { } } } - variant.outputs.all { - def isGoogle = "链接" - if (rootProject.ext.manifestPlaceholders.isGooglePlay == 1) { - isGoogle = "谷歌" - } else if (rootProject.ext.manifestPlaceholders.isGooglePlay == 2) { - isGoogle = "Huawei" - } else if (rootProject.ext.manifestPlaceholders.isGooglePlay == 3) { - isGoogle = "Samsung" + variant.outputs.all { vt -> + println("输出文件名:${vt}") + def channel = '' + def server='' + if (variant.name.startsWith('huawei')) { + channel = "华为" + } else if (variant.name.startsWith('samsung')) { + channel = "三星" + } else if (variant.name.startsWith('google')) { + channel = "谷歌" + } else { + channel = "链接" } - def isPlugin = "完整" - if (rootProject.ext.manifestPlaceholders.isPluginModel) { - isPlugin = "插件" + if(variant.name.contains('online')){ + server='正式服' + }else{ + server='测试服' } - def isTest = "测试服" - if (rootProject.ext.manifestPlaceholders.serverHost == "https://napi.yaoulive.com") { - isTest = "正式服" + outputFileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${channel}-${server}-${variant.buildType.name}.apk" + } + tasks.named("sign${variant.name.capitalize()}Bundle", com.android.build.gradle.internal.tasks.FinalizeBundleTask) { + File file = finalBundleFile.asFile.get() + def channel = '' + if (variant.name.startsWith('huawei')) { + channel = "华为" + } else if (variant.name.startsWith('samsung')) { + channel = "三星" + } else if (variant.name.startsWith('google')) { + channel = "谷歌" + } else { + channel = "链接" + } + File finalFile = new File(file.parentFile, "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${channel}-${variant.buildType.name}.aab") + finalBundleFile.set(finalFile) + } + project.afterEvaluate { project -> + project.tasks.each { + if (it.name.startsWith('assemble') && it.name.endsWith('Release')) { + it.doLast { + def dir = it.name.replace('assemble', '').replace('Release', '').toLowerCase() + println("处理assembleRelease ${project.rootDir}\\app\\$dir\\release\\ | " + new File("${project.rootDir}\\app\\$dir\\release\\").exists()) + if (new File("${project.rootDir}\\app\\$dir\\release\\").exists()) { + println("准备拷贝apk文件") + copy { + from file("${project.rootDir}\\app\\$dir\\release\\") + into file("${project.rootDir}\\outputs\\apk\\") + include '**/*.apk' + } + + } + println("打包apk结束") + } + } else if (it.name.startsWith('sign') && it.name.endsWith('ReleaseBundle')) { + it.doLast { + def dir = it.name.replace('sign', '').replace('ReleaseBundle', '').toLowerCase() + println("处理signReleaseBundle ${project.rootDir}\\app\\$dir\\release\\ | " + new File("${project.rootDir}\\app\\$dir\\release\\").exists()) + if (new File("${project.rootDir}\\app\\$dir\\release\\").exists()) { + println("准备拷贝aab文件") + copy { + from file("${project.rootDir}\\app\\$dir\\release\\") + into file("${project.rootDir}\\outputs\\aab\\") + include '**/*.aab' + } + + } + println("打包aab结束") + } + } } - outputFileName = "[${new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${isGoogle}-${isPlugin}-${variant.buildType.name}-${isTest}.apk" } } signingConfigs { @@ -258,7 +271,7 @@ android { ndk { // TODO: 谷歌商城需要兼容两个平台 //abiFilters "armeabi-v7a", "arm64-v8a" - abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64" + abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" } javaCompileOptions { annotationProcessorOptions { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index adc2c0efc..adb6d14b2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,7 @@ +