Ahmed Riyadh
05/28/2024, 9:09 PM// module1/Utils.kt
fun onePlusOne() = 1 + 1
// module2/Utils.kt
fun onePlusTwo() 1 + 2
And let's say the module1
depends on module2
and use all the code and functions from module2
Then this would cause runtime exception: Exception in thread "main" java.lang.NoSuchMethodError
When calling onePlusTwo
from module2
in module1
(both are applications in this case)
For more details: https://youtrack.jetbrains.com/issue/KT-64744/NoSuchMethodError-on-some-but-not-all-methods-from-another-Gradle-module
This might be a feature, but it allow you to compile the code instead of causing a build failure
Wondering how can we solve this, because I depends on Gradle modules too much.
and use all the code from
A workaround is to change the file name Utils
for one of the modulesephemient
05/28/2024, 9:22 PMAhmed Riyadh
05/28/2024, 9:41 PMval currentSystem = ""
fun getCurrentSystem() = ""
Will cause a build failure (Platform declaration clash: The following declarations have the same JVM signature
) which is a good thing to prevent unexpected bugs,
This might be the main reason the issue in youtrack is not closed yet.
Other than that, it can be fixed very easily by either using a different package or file name in the module where it has the issue