mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-28 04:20:20 +02:00
144 lines
4.3 KiB
Groovy
144 lines
4.3 KiB
Groovy
import groovy.json.JsonSlurper
|
|
|
|
plugins {
|
|
id 'com.android.application'
|
|
id 'org.jetbrains.kotlin.android'
|
|
}
|
|
|
|
def appVersionName = "0.1.0"
|
|
def appVersionCode = 1
|
|
def lspatchReleaseUrl = "https://api.github.com/repos/LSPosed/LSPatch/releases/latest"
|
|
|
|
android {
|
|
compileSdk 33
|
|
buildToolsVersion = "33.0.2"
|
|
|
|
defaultConfig {
|
|
applicationId "me.rhunk.snapenhance"
|
|
minSdk 29
|
|
targetSdk 33
|
|
versionCode appVersionCode
|
|
versionName appVersionName
|
|
multiDexEnabled true
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
shrinkResources false
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
}
|
|
|
|
applicationVariants.configureEach { variant ->
|
|
variant.outputs.configureEach {
|
|
outputFileName = "app-${appVersionName}-${variant.flavorName}.apk"
|
|
}
|
|
}
|
|
|
|
flavorDimensions "release"
|
|
|
|
productFlavors {
|
|
armv8 {
|
|
getIsDefault().set(true)
|
|
ndk {
|
|
abiFilters "arm64-v8a"
|
|
}
|
|
dimension "release"
|
|
}
|
|
armv7 {
|
|
ndk {
|
|
abiFilters "armeabi-v7a"
|
|
}
|
|
dimension "release"
|
|
}
|
|
prod {
|
|
ndk {
|
|
abiFilter("none")
|
|
}
|
|
dimension "release"
|
|
}
|
|
}
|
|
|
|
kotlinOptions {
|
|
jvmTarget = '1.8'
|
|
}
|
|
namespace 'me.rhunk.snapenhance'
|
|
}
|
|
|
|
afterEvaluate {
|
|
getTasks().getByPath(":app:assembleProdDebug").doLast {
|
|
def apkReleaseFile = android.applicationVariants.find { it.buildType.name == "release" && it.flavorName == "prod" }.outputs[0].outputFile
|
|
|
|
//download the target apk
|
|
println "Downloading target apk"
|
|
def targetApkFile = new File("${buildDir}/${apkReleaseFile.name}")
|
|
try {
|
|
def targetApkUrl = project.property("targetApkUrl")
|
|
targetApkFile.withOutputStream { out ->
|
|
new URL(targetApkUrl).withInputStream { input ->
|
|
out << input
|
|
}
|
|
}
|
|
} catch (Throwable ignored) {
|
|
println "No target apk url provided"
|
|
return
|
|
}
|
|
|
|
//download the latest lspatch jar
|
|
def connection = new URL(lspatchReleaseUrl).openConnection()
|
|
def json = new JsonSlurper().parseText(connection.getInputStream().getText())
|
|
def downloadUrl = json.assets[0].browser_download_url
|
|
println "Downloading LSPatch from ${downloadUrl}"
|
|
|
|
def lspatchJarfile = new File("${buildDir}/lspatch.jar")
|
|
lspatchJarfile.withOutputStream { out ->
|
|
new URL(downloadUrl).withInputStream { input ->
|
|
out << input
|
|
}
|
|
}
|
|
|
|
println "Executing LSPatch"
|
|
exec {
|
|
commandLine "java", "-jar", lspatchJarfile.absolutePath,
|
|
targetApkFile.absolutePath,
|
|
"--force", "-l", "2", "-m",
|
|
apkReleaseFile.absolutePath,
|
|
"-o",
|
|
"${buildDir}/outputs/apk/lspatch/debug/"
|
|
}
|
|
}
|
|
|
|
//auto install for debug purpose
|
|
getTasks().getByPath(":app:assembleArmv8Debug").doLast {
|
|
def apkDebugFile = android.applicationVariants.find { it.buildType.name == "debug" && it.flavorName == "armv8" }.outputs[0].outputFile
|
|
try {
|
|
println "Killing Snapchat"
|
|
exec {
|
|
commandLine "adb", "shell", "am", "force-stop", "com.snapchat.android"
|
|
}
|
|
println "Installing debug build"
|
|
exec() {
|
|
commandLine "adb", "install", "-r", "-d", apkDebugFile.absolutePath
|
|
}
|
|
println "Starting Snapchat"
|
|
exec {
|
|
commandLine "adb", "shell", "am", "start", "com.snapchat.android"
|
|
}
|
|
} catch (Throwable t) {
|
|
println "Failed to install debug build"
|
|
t.printStackTrace()
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'
|
|
compileOnly files('libs/LSPosed-api-1.0-SNAPSHOT.jar')
|
|
implementation 'com.google.code.gson:gson:2.10.1'
|
|
implementation 'com.arthenica:ffmpeg-kit-min-gpl:5.1'
|
|
} |