From 5f64e40a7ea02579b3160637c04cef6fd586e6cf Mon Sep 17 00:00:00 2001 From: CranberrySoup <142951702+CranberrySoup@users.noreply.github.com> Date: Wed, 3 Jul 2024 01:42:10 +0000 Subject: [PATCH] Fix debug exceptions in releases (#1168) --- app/build.gradle.kts | 11 ++++++++--- library/build.gradle.kts | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 43cd0d83..9c75a90d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,7 +14,6 @@ plugins { val tmpFilePath = System.getProperty("user.home") + "/work/_temp/keystore/" val prereleaseStoreFile: File? = File(tmpFilePath).listFiles()?.first() -var isLibraryDebug = false fun String.execute() = ByteArrayOutputStream().use { baot -> if (project.exec { @@ -105,7 +104,6 @@ android { ) } debug { - isLibraryDebug = true isDebuggable = true applicationIdSuffix = ".debug" proguardFiles( @@ -236,7 +234,14 @@ dependencies { implementation("com.github.Blatzar:NiceHttp:0.4.11") // HTTP Lib implementation(project(":library") { - this.extra.set("isDebug", isLibraryDebug) + // There does not seem to be a good way of getting the android flavor. + val isDebug = gradle.startParameter.taskRequests.any { task -> + task.args.any { arg -> + arg.contains("debug", true) + } + } + + this.extra.set("isDebug", isDebug) }) } diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 42a8c943..46da8e84 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -38,6 +38,11 @@ buildkonfig { defaultConfigs { val isDebug = kotlin.runCatching { extra.get("isDebug") }.getOrNull() == true + if (isDebug) { + logger.quiet("Compiling library with debug flag") + } else { + logger.quiet("Compiling library with release flag") + } buildConfigField(FieldSpec.Type.BOOLEAN, "DEBUG", isDebug.toString()) } } @@ -65,4 +70,4 @@ publishing { groupId = "com.lagradost.api" } } -} \ No newline at end of file +}