Reputation: 439
I want to integrate a code of an SDK written in Kotlin which consists of some imports and some methods like onCreate(), onIntent() etc. in my Android application written in Java which also has the same methods (I want to merge those same methods). However, my application has lots of Java classes, and the Kotlin code is needed only in one class. When I convert that class to Kotlin, it becomes so difficult to handle all errors generated from different Java classes, so I don't want to convert that Java class to Kotlin.
So, how can I solve this issue? Should I convert the Kotlin code to Java or is there any other solution?
Thanks in advance...
Upvotes: 1
Views: 1054
Reputation: 2158
You don't need to convert Kotlin into Java or vice versa. You can work with both languages in a single project.
Since you are working on an Android project, then both Kotlin and Java are compiled into JVM bytecode. For that reason, you can call Kotlin classes into Java and the opposite.
I would suggest to have a look Kotlin - Java interoperability guide.
Upvotes: 2