Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 3.0 Preview Missing Imports when refactoring Kotlin code

Whenever I try to refactor Koltin code on Android Studio 3.0 it simply removes all my "top level" imports and starts using "inplace" imports.

By refactoring I mean, in this case, moving code around. So let's say I have a class under com.myapp package. If I move it to com.myapp.anotherpackage this issue happens

Funny fact about this looks like it only happens when you move more than one file at the same time

What it looks like:

//Before refactoring I have this import
import android.support.v7.app.AppCompatActivity;

class MyActivity : AppCompatActivity() {
    //code
}

Then after refactoring it goes like this

//"top level" import is gone

class MyActivity : android.support.v7.app.AppCompatActivity() { //"inline" import
    //code
}

enter image description here

It gets even worse if I have to refactor the code again, as every single import is "inlined", the android studio doesn't refactor those, and I have to do fix them by hand. This is getting really annoying already, as I had to fix over 100 of these. Any thoughts on how to fix this?

like image 761
Jefferson Tavares Avatar asked May 23 '17 11:05

Jefferson Tavares


1 Answers

This is very similar to bug which was fixed not long ago. The relevant changes weren't included to the Kotlin plugin bundled with a As3.0 preview yet. But they will be available in the next plugin update.

like image 120
Aleksei Sedunov Avatar answered Sep 25 '22 02:09

Aleksei Sedunov