From f1a1aae78797ad3c63592c939f7e8ae7f156c077 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 27 Jun 2024 14:28:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=93=E5=8C=85=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E5=85=BC=E5=AE=B9=E4=BD=8E=E7=89=88=E6=9C=AC?= =?UTF-8?q?AndroidStudio=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IAP6Helper/build.gradle | 1 + app/build.gradle | 116 ++++++++++++++++------------------------ config.gradle | 4 +- package_config.gradle | 7 +++ 4 files changed, 55 insertions(+), 73 deletions(-) diff --git a/IAP6Helper/build.gradle b/IAP6Helper/build.gradle index ba734c03e..29919cb60 100644 --- a/IAP6Helper/build.gradle +++ b/IAP6Helper/build.gradle @@ -23,4 +23,5 @@ android { } dependencies { + // api 'com.google.code.gson:gson:2.8.8' } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d7065ed3b..8a4c9350e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,10 +4,8 @@ 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 - } project.tasks.getByName("tasks").doFirst { } @@ -90,12 +88,13 @@ android { applicationVariants.all { variant -> println "清空build文件夹"; - for (final def project in rootProject.getAllprojects()) { + /* for (final def project in rootProject.getAllprojects()) { def name = variant.name.replace('Debug', '').replace('Release', '').toLowerCase() delete project.buildDir - delete 'app' + File.separator + name + delete project.rootDir.absolutePath+File.separator+"app"+File.separator+name println project.buildDir - } + }*/ + //delete project.rootDir.absolutePath + File.separator + "outputs" String variantName = variant.name.capitalize() def processManifestTask = project.tasks.getByName("process${variantName}Manifest") processManifestTask.doLast { pm -> @@ -160,29 +159,39 @@ android { } } } - variant.outputs.all { vt -> - println("输出文件名:${vt}") + variant.assemble.doLast { vt -> def channel = '' - def server='' - if (variant.name.startsWith('huawei')) { + def server = '' + if (variant.name.contains('huawei')) { channel = "华为" - } else if (variant.name.startsWith('samsung')) { + } else if (variant.name.contains('samsung')) { channel = "三星" - } else if (variant.name.startsWith('google')) { + } else if (variant.name.contains('google')) { channel = "谷歌" } else { channel = "链接" } - if(variant.name.contains('online')){ - server='正式服' - }else{ - server='测试服' + if (variant.name.contains('online')) { + server = '正式服' + } else { + server = '测试服' } - outputFileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${channel}-${server}-${variant.buildType.name}.apk" + def fileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${defaultConfig.versionCode}-${channel}-${server}-${variant.buildType.name}.apk" + variant.outputs.forEach { fe -> + copy { + from fe.outputFile + into file("${project.rootDir}\\outputs\\apk\\") + rename { fn -> + fileName + } + } + } + } tasks.named("sign${variant.name.capitalize()}Bundle", com.android.build.gradle.internal.tasks.FinalizeBundleTask) { File file = finalBundleFile.asFile.get() def channel = '' + def server = '' if (variant.name.startsWith('huawei')) { channel = "华为" } else if (variant.name.startsWith('samsung')) { @@ -192,43 +201,14 @@ android { } 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结束") - } - } + if (variant.name.contains('online')) { + server = '正式服' + } else { + server = '测试服' } + def fileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${defaultConfig.versionCode}-${channel}-${server}-${variant.buildType.name}.aab" + File finalFile = new File("${project.rootDir}\\outputs\\aab", fileName) + finalBundleFile.set(finalFile) } } signingConfigs { @@ -269,9 +249,17 @@ android { manifestPlaceholders = rootProject.ext.manifestPlaceholders multiDexEnabled true ndk { - // TODO: 谷歌商城需要兼容两个平台 - //abiFilters "armeabi-v7a", "arm64-v8a" - abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" + Gradle gradle = getGradle() + String tskReqStr = gradle.getStartParameter().getTaskRequests().args.toString() + println("处理ndk 版本 = " + tskReqStr) + def isLink = tskReqStr.contains("Link") + if (isLink) { + abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" + println("打包ndk 链接") + } else { + abiFilters "armeabi-v7a", "arm64-v8a" + println("打包ndk其他") + } } javaCompileOptions { annotationProcessorOptions { @@ -326,18 +314,4 @@ dependencies { //debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10' -} -// 链接包需要注释掉 否正无法更新 谷歌包需要打开 -/* -project.afterEvaluate { - android.applicationVariants.all { variant -> - variant.outputs.each { output -> - output.processResources.doFirst { pm-> - String manifestPath = output.processResources.manifestFile; - def manifestContent = file(manifestPath).getText() - manifestContent = manifestContent.replace('android.permission.REQUEST_INSTALL_PACKAGES', '') - file(manifestPath).write(manifestContent) - } - } - } -}*/ +} \ No newline at end of file diff --git a/config.gradle b/config.gradle index 68c8d3f84..3f81a20b3 100644 --- a/config.gradle +++ b/config.gradle @@ -4,8 +4,8 @@ ext { buildToolsVersion: "29.0.2", minSdkVersion : 21, targetSdkVersion : 33, - versionCode : 678, - versionName : "6.7.0" + versionCode : 681, + versionName : "6.7.1" ] manifestPlaceholders = [ //正式、 diff --git a/package_config.gradle b/package_config.gradle index da551c1dd..5397b1b5f 100644 --- a/package_config.gradle +++ b/package_config.gradle @@ -1,4 +1,11 @@ android{ + dexOptions { + jumboMode = true + javaMaxHeapSize "8g" + preDexLibraries = true + threadCount = 8 + } + flavorDimensions 'packageApk' productFlavors { link_test {