mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 14:52:13 -04:00
Resolve namespace issues for compatibility with Gradle 8.0 and above. * In compliance with the requirement to specify a namespace for each module, we have eliminated package names from manifests and introduced namespace declarations in the Gradle files. * Considering the presence of multiple apps in the custom app, we configured the namespace during the creation of product flavors. * To enhance clarity and understanding, comprehensive comments have been added.
This commit is contained in:
parent
0f65ebeff9
commit
2a9bbe71b3
@ -20,6 +20,9 @@ fun generateVersionName() = "${Config.versionMajor}.${Config.versionMinor}.${Con
|
|||||||
val apkPrefix get() = System.getenv("TAG") ?: "kiwix"
|
val apkPrefix get() = System.getenv("TAG") ?: "kiwix"
|
||||||
|
|
||||||
android {
|
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"
|
namespace = "org.kiwix.kiwixmobile"
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
base.archivesName.set(apkPrefix)
|
base.archivesName.set(apkPrefix)
|
||||||
|
@ -43,9 +43,18 @@ class AllProjectConfigurer {
|
|||||||
target.plugins.apply("androidx.navigation.safeargs")
|
target.plugins.apply("androidx.navigation.safeargs")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun configureBaseExtension(target: Project) {
|
fun configureBaseExtension(target: Project, isLibrary: Boolean) {
|
||||||
target.configureExtension<BaseExtension> {
|
target.configureExtension<BaseExtension> {
|
||||||
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)
|
setCompileSdkVersion(Config.compileSdk)
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = Config.minSdk
|
minSdk = Config.minSdk
|
||||||
|
@ -33,10 +33,10 @@ class KiwixConfigurationPlugin : Plugin<Project> {
|
|||||||
target.plugins.all {
|
target.plugins.all {
|
||||||
when (this) {
|
when (this) {
|
||||||
is LibraryPlugin -> {
|
is LibraryPlugin -> {
|
||||||
doDefaultConfiguration(target)
|
doDefaultConfiguration(target, true)
|
||||||
}
|
}
|
||||||
is AppPlugin -> {
|
is AppPlugin -> {
|
||||||
doDefaultConfiguration(target)
|
doDefaultConfiguration(target, false)
|
||||||
appConfigurer.configure(target)
|
appConfigurer.configure(target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,8 +47,8 @@ class KiwixConfigurationPlugin : Plugin<Project> {
|
|||||||
allProjectConfigurer.configureJacoco(target)
|
allProjectConfigurer.configureJacoco(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doDefaultConfiguration(target: Project) {
|
private fun doDefaultConfiguration(target: Project, isLibrary: Boolean) {
|
||||||
allProjectConfigurer.configureBaseExtension(target)
|
allProjectConfigurer.configureBaseExtension(target, isLibrary)
|
||||||
allProjectConfigurer.configureCommonExtension(target)
|
allProjectConfigurer.configureCommonExtension(target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,10 @@ android {
|
|||||||
productFlavors.apply {
|
productFlavors.apply {
|
||||||
CustomApps.createDynamically(project.file("src"), this)
|
CustomApps.createDynamically(project.file("src"), this)
|
||||||
all {
|
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 {
|
File("$projectDir/src", "$name/$name.zim").let {
|
||||||
createDownloadTask(it)
|
createDownloadTask(it)
|
||||||
createPublishApkWithExpansionTask(it, applicationVariants)
|
createPublishApkWithExpansionTask(it, applicationVariants)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
package="org.kiwix.kiwixmobile.custom">
|
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
Loading…
x
Reference in New Issue
Block a user