I’m a Kotlin user who primarily uses it as a Java replacement in server-side projects. There are many excellent Java tools such as MapStruct, QueryDSL, and more that rely on annotation processors and code generation in order to work. However, using these tools with IntelliJ is complicated, especially when using Maven.
Currently, the kapt tool works well if invoked directly by Maven CLI commands (or the IntelliJ GUI that allows for invoking said CLI commands). However, IntelliJ itself will not properly run kapt as part of its own Kotlin build system. This makes it deeply frustrating to work on a project in Kotlin with annotation processors, as there is no “one click” build step within IntelliJ.
It appears that JetBrains has been ignoring this issue for several years already. What concerns me more is the fact that kapt is in maintenance mode, deprecated in favor of the new KSP tool. While I’m totally fine with the idea of moving to newer and better tools, from what I’ve read about KSP so far it is not compatible with traditional annotation processors (I might be wrong about that, it’s just the impression I have so far). This makes it less likely that JetBrains will resolve the current limitations of kapt, and more likely that they will be moving further away from proper support for Java annotation processors.
As someone who loves using Kotlin instead of Java alongside the broader Java ecosystem, this is very concerning to me. I especially feel it will hinder Kotlin’s adoption in the enterprise space, where Java is still king but a lot of developers (including myself) are slowly increasing Kotlin’s adoption.
I hope I’m misinterpreting what is happening, but I’m deeply upset by this change. I hope that better solutions come forward in the future.
Any feedback, bug reports, contributions, etc. would be welcome. A sync/replication engine is in process. This is all open source under an Apache license.
Would like some advice for what is the most Kotlin idiomatic way to build a double-linked tree structure. Each node in the tree can have zero or more children, and every node other than the root has exactly one parent. After it has been constructed the tree is immutable. I need to be able to traverse the tree from bottom up as well as top down.
At present I’m building the tree bottom up, then doing a post build pass through the tree filling in each node’s parent. So each node contains properties:-
private val children : List<Node>
private var parent : Node?
Which works fine, but I don’t much like the way I have parent exposed as var when it is immutable after the post-build stage, as this blocks kotlin’s null smart casts. I can’t make parent lateinit as I need the null value for the tree root.
I could alternatively build the tree top down, passing the parent as an argument to child constructor, and having the child call back to add itself.
private val children : MutableList<Node>
private val parent : Node?
This avoids the second pass, makes everything val and allows null smart casts. But to me that feels worse as it implies the number of children at a node is mutable.
What do people consider is the more idiomatic?
Sometimes I receive errors like ”java… error” when using Kotlin. Is Kotlin using Java internally or I am missing something? I know that there is some level of interoperability between the two, but that is a little bit strange since I’m not calling anything from Java explicitly.
Hey guys. Was working on a project where I needed continuous access to background location. I leverage location access inside a background job and then send the fetched lat/lng to a server via API calls. These API calls are present inside a service. But I’ve noticed Android kills the service when it runs in background on a few devices. Any idea what a better approach could be ?
I am long time android/kotlin developer, my python skills are lacking.
i want to make a kotlin/python hybrid but cant understand python environments, till today i been using it “normal” in windows environment.
i am able to execute command line code (with default windows env) from kotlin, but cant make it work with conda.
can someone point me in the right direction?
Hey, so I am working on a simple note app in which I am using Koin to learn it. In the app, there’s a NotesFragment that shows notes and InsertNotesFragment, that shows details of a clicked note or in which you can insert a new note.
In the InsertNotesFragment, there’s a button that also shows up a BottomSheetDialogFragment, in which one can select a color for a new/existing note.
InsertNotesFragment can be opened by clicking an existing note (note editing mode) or by clicking an add button in the NotesFragment (note inserting mode).
Now, InsertNotesFragment and BottomSheetDialogFragment are supposed to share a ViewModel with a StateFlow object that represents Note’s state.
data class Note( val id: Int? = 0, val title: String? = "", val content: String? = "", val date: String? = "", val color: Int? = Color.parseColor("#ffffff") )
Note’s StateFlow in the shared view model:
private val _noteState = MutableStateFlow(Note()) val noteState: StateFlow<Note> = _noteState.asStateFlow()
It should work in a way that for example changing title or content text in InsertNotesFragment should update the note’s StateFlow “title” and “content” values and changing the color in BottomSheetDialogFragment should change the note’s StateFlow “color” value.
To share the viewModel instance, I am using Koin’s sharedStateViewModel, as I am injecting SavedStateHandle into the shared view model (so I can retrieve navigation arguments – I am passing id of the clicked note to load note’s details).
When I for example click the add button, the shared view model gets initialized. However, when I then press the back button and click the add button again, the screen (InsertNotesFragment) shows but the shared view model does not initialize again as I would expect – the view model instance stays alive for some reason. Not only that, the value passed in navigation arguments is never retrieved in the savedstatehandle. This is the way I am trying to get those arguments in viewmodel
val id = InsertNotesFragmentArgs.fromSavedStateHandle(savedStateHandle).noteId
I don’t really know what I am doing wrong here. I’ve used saved state handle with Compose Navigation in the past this way and it worked great. I thought it would be the same with XML Navigation. I am also not sure why viewmodel persists when I close the InsertNotesFragment with a back press.
I am probably missing some knowledge that I am unaware of and I am not sure on how to fix this. If there’s someone who uses Koin regularly and could help me, it would be really appreciated.
In this post, I will show you how to do Firebase authentication using SMS.
I heard the android beam is deprecated since api 29.
Google perfers to use bluetooth.
But i wonder that is it possible to make two android devices detect each other by using NFC.
Please help me