Does anyone managed to fixed this issue? It happe...
# gradle
a
Does anyone managed to fixed this issue? It happen when you have:
Copy code
// module1/Utils.kt
fun onePlusOne() = 1 + 1
Copy code
// 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 modules
e
you should use different packages in different modules - that's good practice, and is forced by JPMS if you ever have to deal with Java 9+ modules
a
The issue is that unexpected bug will happen at runtime, other bugs will be prevented by the compiler, for example if you used:
Copy code
val 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