379 lines
17 KiB
Groovy
379 lines
17 KiB
Groovy
apply plugin: 'com.android.application'
|
||
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 {
|
||
namespace "com.pandoralive.shayu"
|
||
/* 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'
|
||
]))
|
||
}
|
||
}
|
||
}*/
|
||
compileSdk rootProject.ext.android.compileSdkVersion
|
||
packagingOptions {
|
||
pickFirst "lib/armeabi/libyuvutils.so"
|
||
pickFirst "lib/arm64-v8a/libyuvutils.so"
|
||
pickFirst "lib/armeabi-v7a/libyuvutils.so"
|
||
pickFirst "lib/armeabi/libyuvtools.so"
|
||
pickFirst "lib/arm64-v8a/libyuvtools.so"
|
||
pickFirst "lib/armeabi-v7a/libyuvtools.so"
|
||
exclude "lib/arm64-v8a/libmmcv_api_handgesture.so"
|
||
exclude "lib/arm64-v8a/libmmcv_api_express.so"
|
||
exclude "lib/arm64-v8a/libMediaEncoder.so"
|
||
exclude "lib/arm64-v8a/libarcore_sdk_c.so"
|
||
exclude "lib/arm64-v8a/libmediadecoder.so"
|
||
exclude "lib/arm64-v8a/libMediaMuxer.so"
|
||
exclude "lib/arm64-v8a/libarcore_sdk_jni.so"
|
||
exclude "lib/arm64-v8a/libMediaUtils.so"
|
||
exclude "lib/arm64-v8a/libcosmosffmpeg.so"
|
||
//旧美颜so
|
||
exclude 'lib/arm64-v8a/libxeengine.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_base.so'
|
||
exclude 'lib/arm64-v8a/libmmcrypto.so'
|
||
exclude 'lib/arm64-v8a/libMNN.so'
|
||
exclude 'lib/arm64-v8a/libc++_shared.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_base.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_beauty.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_bodylandmark.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_express.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_faceattributes.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_facefeatures.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_faceprocessor.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_facerecognition.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_handgesture.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_imagequality.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_objectdetect.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_segmentation.so'
|
||
exclude 'lib/arm64-v8a/libmmcv_api_videoprocessor.so'
|
||
exclude 'lib/arm64-v8a/libmmlic.so'
|
||
exclude 'lib/arm64-v8a/libMNN_CL.so'
|
||
exclude 'lib/arm64-v8a/libMNN_Express.so'
|
||
exclude 'lib/armeabi-v7a/libxeengine.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_base.so'
|
||
exclude 'lib/armeabi-v7a/libmmcrypto.so'
|
||
exclude 'lib/armeabi-v7a/libMNN.so'
|
||
exclude 'lib/armeabi-v7a/libc++_shared.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_base.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_beauty.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_bodylandmark.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_express.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_faceattributes.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_facefeatures.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_faceprocessor.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_facerecognition.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_handgesture.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_imagequality.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_objectdetect.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_segmentation.so'
|
||
exclude 'lib/armeabi-v7a/libmmcv_api_videoprocessor.so'
|
||
exclude 'lib/armeabi-v7a/libmmlic.so'
|
||
exclude 'lib/armeabi-v7a/libMNN_CL.so'
|
||
exclude 'lib/armeabi-v7a/libMNN_Express.so'
|
||
//美颜
|
||
if (rootProject.ext.manifestPlaceholders.isPluginModel) {
|
||
exclude 'lib/armeabi-v7a/libCNamaSDK.so'
|
||
exclude 'lib/arm64-v8a/libCNamaSDK.so'
|
||
exclude 'lib/armeabi-v7a/libfuai.so'
|
||
exclude 'lib/arm64-v8a/libfuai.so'
|
||
}
|
||
|
||
}
|
||
compileOptions {
|
||
sourceCompatibility JavaVersion.VERSION_18
|
||
targetCompatibility JavaVersion.VERSION_18
|
||
}
|
||
buildFeatures {
|
||
buildConfig = true
|
||
}
|
||
|
||
|
||
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 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 ->
|
||
String manifestPath = "build/intermediates/merged_manifests/google_onlineRelease/processGoogle_onlineReleaseManifest/AndroidManifest.xml"
|
||
def isGooglePlay = variant.name.contains("google")
|
||
println "谷歌版本:" + isGooglePlay
|
||
println "文件存在" + file(manifestPath).exists()
|
||
println "" + (isGooglePlay == 1)
|
||
println "" + (file(manifestPath).exists() && isGooglePlay)
|
||
if (file(manifestPath).exists() && isGooglePlay) {
|
||
def manifestContent = file(manifestPath).getText()
|
||
println "移除权限"
|
||
manifestContent = manifestContent.replace('<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />', '')
|
||
file(manifestPath).write(manifestContent)
|
||
} else {
|
||
print "not Exists = " + manifestPath
|
||
}
|
||
if (file(manifestPath).exists() && isGooglePlay) {
|
||
def manifestContent = file(manifestPath).getText()
|
||
println "移除权限2"
|
||
manifestContent = manifestContent.replace('<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />', '')
|
||
file(manifestPath).write(manifestContent)
|
||
|
||
}
|
||
}
|
||
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',
|
||
//旧美颜
|
||
'model-all.zip',
|
||
'filterData.zip',
|
||
'KSYResource/*',
|
||
'Resources/*',
|
||
'Asset/*',
|
||
'image_effect_shaders/*',
|
||
'internal/*'
|
||
//美颜基础组件
|
||
|
||
]))
|
||
println "isPluginModel = " + rootProject.ext.manifestPlaceholders.isPluginModel
|
||
if (rootProject.ext.manifestPlaceholders.isPluginModel) {
|
||
delete(fileTree(dir: outputDir, includes: [
|
||
'model/ai_face_processor_lite.bundle',
|
||
'model/ai_face_processor.bundle',
|
||
'graphics/face_beautification.bundle'
|
||
]))
|
||
} else {
|
||
println "不删除bundle"
|
||
}
|
||
}
|
||
}
|
||
variant.assemble.doLast { vt ->
|
||
def channel = ''
|
||
def server = ''
|
||
if (variant.name.contains('huawei')) {
|
||
channel = "华为"
|
||
} else if (variant.name.contains('samsung')) {
|
||
channel = "三星"
|
||
} else if (variant.name.contains('google')) {
|
||
channel = "谷歌"
|
||
} else {
|
||
channel = "链接"
|
||
}
|
||
if (variant.name.contains('online')) {
|
||
server = '正式服'
|
||
} else {
|
||
server = '测试服'
|
||
}
|
||
def fileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]潘多拉-${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.contains('samsung')) {
|
||
channel = "三星"
|
||
} else if (variant.name.contains('google')) {
|
||
channel = "谷歌"
|
||
} else {
|
||
channel = "链接"
|
||
}
|
||
if (variant.name.contains('online')) {
|
||
server = '正式服'
|
||
} else {
|
||
server = '测试服'
|
||
}
|
||
def fileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]潘多拉-${defaultConfig.versionName}-${defaultConfig.versionCode}-${channel}-${server}-${variant.buildType.name}.aab"
|
||
File finalFile = new File("${project.rootDir}\\outputs\\aab", fileName)
|
||
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结束")
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
signingConfigs {
|
||
release {
|
||
keyAlias 'phonelive'
|
||
keyPassword 'phonelive'
|
||
storeFile file('../hdl.jks')
|
||
storePassword 'phonelive'
|
||
}
|
||
//陌陌本地配置需要
|
||
config {//TODO BEAUTYSDK 这里需要配置keystore相关信息
|
||
keyAlias 'phonelive'
|
||
keyPassword 'phonelive'
|
||
storeFile file('../hdl.jks')//keystore的存放路径
|
||
storePassword 'phonelive'
|
||
v2SigningEnabled true // android 5.0-8.0,必须用V2,否则会有安全问题
|
||
v1SigningEnabled true
|
||
}
|
||
}
|
||
aaptOptions {
|
||
cruncherEnabled = false
|
||
useNewCruncher = false
|
||
}
|
||
|
||
packagingOptions {//加上这写代码 为了mob兼容性androidx
|
||
// pickFirst 'META-INF/*'
|
||
}
|
||
|
||
|
||
defaultConfig {
|
||
// applicationId "myname.pdlive.shayu"
|
||
applicationId "com.pandora.sy"
|
||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||
//版本在这里修改
|
||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||
versionCode rootProject.ext.android.versionCode
|
||
versionName rootProject.ext.android.versionName
|
||
manifestPlaceholders = rootProject.ext.manifestPlaceholders
|
||
multiDexEnabled true
|
||
ndk {
|
||
// TODO: 谷歌商城需要兼容两个平台
|
||
Gradle gradle = getGradle()
|
||
String tskReqStr = gradle.getStartParameter().getTaskRequests().args.toString()
|
||
println("处理ndk 版本 = " + tskReqStr)
|
||
def isLink = tskReqStr.contains("Link")
|
||
if (isLink) {//移除32位so库可以有效降低包体大小,等需要时再弄
|
||
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
|
||
//abiFilters "arm64-v8a", "x86_64"
|
||
println("打包ndk 链接")
|
||
} else {
|
||
abiFilters "armeabi-v7a", "arm64-v8a"
|
||
//abiFilters "arm64-v8a"
|
||
println("打包ndk其他")
|
||
}
|
||
|
||
}
|
||
javaCompileOptions {
|
||
annotationProcessorOptions {
|
||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||
}
|
||
}
|
||
}
|
||
buildTypes {
|
||
release {
|
||
minifyEnabled true
|
||
shrinkResources true
|
||
zipAlignEnabled true
|
||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||
signingConfig signingConfigs.release
|
||
}
|
||
debug {
|
||
minifyEnabled false
|
||
shrinkResources false
|
||
zipAlignEnabled false
|
||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||
signingConfig signingConfigs.release
|
||
}
|
||
}
|
||
lintOptions {
|
||
checkReleaseBuilds false
|
||
abortOnError false
|
||
}
|
||
}
|
||
|
||
|
||
repositories {
|
||
flatDir {
|
||
dirs 'libs', '../libs'
|
||
}
|
||
}
|
||
|
||
dependencies {
|
||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||
//implementation platform('com.google.firebase:firebase-bom:30.5.0')
|
||
//implementation 'com.google.firebase:firebase-crashlytics'
|
||
|
||
//直播
|
||
api project(':main')
|
||
//短视频
|
||
api project(':video')
|
||
|
||
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
|
||
|
||
// implementation rootProject.ext.dependencies["leakcanary"]
|
||
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
|
||
|
||
|
||
}
|