diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 66bf6f798..ae41837ad 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -20,6 +20,9 @@ fun generateVersionName() = "${Config.versionMajor}.${Config.versionMinor}.${Con val apkPrefix get() = System.getenv("TAG") ?: "kiwix" android { + // Added namespace in response to Gradle 8.0 and above. + // This is now specified in the Gradle configuration instead of declaring + // it directly in the AndroidManifest file. namespace = "org.kiwix.kiwixmobile" defaultConfig { base.archivesName.set(apkPrefix) diff --git a/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt b/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt index 7bff2971e..406df427a 100644 --- a/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt +++ b/buildSrc/src/main/kotlin/plugin/AllProjectConfigurer.kt @@ -43,9 +43,18 @@ class AllProjectConfigurer { target.plugins.apply("androidx.navigation.safeargs") } - fun configureBaseExtension(target: Project) { + fun configureBaseExtension(target: Project, isLibrary: Boolean) { target.configureExtension { - namespace = "" + // The namespace cannot be directly set in `LibraryExtension`. + // The core module is configured as a library for both Kiwix and custom apps. + // Therefore, we set the namespace in `BaseExtension` for the core module, + // based on the boolean value of `isLibrary`. This value is passed from the + // `KiwixConfigurationPlugin`. If the current plugin is `LibraryPlugin`, + // indicating it is the core module, then this value will be true, + // and we set the namespace accordingly. + if (isLibrary) { + namespace = "org.kiwix.kiwixmobile.core" + } setCompileSdkVersion(Config.compileSdk) defaultConfig { minSdk = Config.minSdk diff --git a/buildSrc/src/main/kotlin/plugin/KiwixConfigurationPlugin.kt b/buildSrc/src/main/kotlin/plugin/KiwixConfigurationPlugin.kt index 855e973f8..7f9973fb0 100644 --- a/buildSrc/src/main/kotlin/plugin/KiwixConfigurationPlugin.kt +++ b/buildSrc/src/main/kotlin/plugin/KiwixConfigurationPlugin.kt @@ -33,10 +33,10 @@ class KiwixConfigurationPlugin : Plugin { target.plugins.all { when (this) { is LibraryPlugin -> { - doDefaultConfiguration(target) + doDefaultConfiguration(target, true) } is AppPlugin -> { - doDefaultConfiguration(target) + doDefaultConfiguration(target, false) appConfigurer.configure(target) } } @@ -47,8 +47,8 @@ class KiwixConfigurationPlugin : Plugin { allProjectConfigurer.configureJacoco(target) } - private fun doDefaultConfiguration(target: Project) { - allProjectConfigurer.configureBaseExtension(target) + private fun doDefaultConfiguration(target: Project, isLibrary: Boolean) { + allProjectConfigurer.configureBaseExtension(target, isLibrary) allProjectConfigurer.configureCommonExtension(target) } } diff --git a/custom/build.gradle.kts b/custom/build.gradle.kts index 584bbc8d7..c2b921dab 100644 --- a/custom/build.gradle.kts +++ b/custom/build.gradle.kts @@ -30,6 +30,10 @@ android { productFlavors.apply { CustomApps.createDynamically(project.file("src"), this) all { + // Added namespace for every custom app to make it compatible with gradle 8.0 and above. + // This is now specified in the Gradle configuration instead of declaring + // it directly in the AndroidManifest file. + namespace = "org.kiwix.kiwixcustom$name" File("$projectDir/src", "$name/$name.zim").let { createDownloadTask(it) createPublishApkWithExpansionTask(it, applicationVariants) diff --git a/custom/src/main/AndroidManifest.xml b/custom/src/main/AndroidManifest.xml index 4d24c4b47..56a8462a9 100644 --- a/custom/src/main/AndroidManifest.xml +++ b/custom/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools">