1

Sometimes when I rename a directory or a class, the references of the corresponding classes (the classes in the directory or the class itself) are replaced by their fully qualified name instead of being imported, which is a bit ugly code wisely.

Example : Before refactoring and renaming :

package com.domain.package1;

public class Class1 {
    public Class1() {
    }
}

package com.domain.package2;

import com.domain.package1;

public class Class2 {
    Class1 class1Instance;
    public Class2() {
        class1Instance = new Class1();
    }
}

after renaming Class1 to Class1New the code becomes like this

package com.domain.package1;

public class Class1New {
    public Class1New() {
    }
}

package com.domain.package2;

public class Class2 {
    com.domain.package1.Class1New class1Instance;
    public Class2() {
        class1Instance = new com.domain.package1.Class1New();
    }
}

or after renaming package1 to package1new the code becomes like this

package com.domain.package1new;

public class Class1 {
    public Class1() {
    }
}

package com.domain.package2;

public class Class2 {
    com.domain.package1new.Class1 class1Instance;
    public Class2() {
        class1Instance = new com.domain.package1new.Class1();
    }
}

I tried unchecking Use fully qualified class names in Settings but nothing changed. Any suggestions?

sanastasiadis
  • 1,182
  • 1
  • 15
  • 23
  • you can check answers of this question. It may help you. http://stackoverflow.com/questions/16804093/android-studio-rename-package? – Khaled Saifullah Nov 04 '16 at 09:30
  • Actually I am using this method but I am not necessarily renaming the root package, I am trying to rename any directory or class in my project but sometimes the class names are replaced by their fully qualified names instead of being imported. – TheProGrammer Nov 04 '16 at 09:45

0 Answers0