0

When I paste some Java code into a Kotlin project, Android Studio can convert the syntax. However, when the converter is invoked, it adds several unused imports to the file, which broke my existing code.

import androidx.core.app.ComponentActivity.ExtraData
import androidx.core.content.ContextCompat.getSystemService
import android.icu.lang.UCharacter.GraphemeClusterBreak.T
import android.R

The pasted code snippet doesn't need these imports. Since I already imported my.application.R but AS adds android.R, references to R. will broke.

Why are these added? Is this a bug in the converter? Can I somehow disable it?

klenium
  • 2,468
  • 2
  • 24
  • 47
  • You can easily use organize imports `Ctrl` + `Atl` + `O` and get rid of them. More on https://stackoverflow.com/questions/16615038/what-is-the-shortcut-to-auto-import-all-in-android-studio – madlymad Nov 17 '19 at 14:15
  • 1
    Of course I can remove them manually, but it's annoying to do all the time. – klenium Nov 17 '19 at 14:18
  • It's likely a code converter bug, try looking it up or reporting at https://youtrack.jetbrains.com/issues. – Egor Nov 17 '19 at 17:25

0 Answers0