Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio adds entire package name for every class instead of importing

Hey I'm not sure what happened but I refactored an Android project of mine recently. When I type the name of a new class the drop down menu appears as usual, prompting me to import it on the fly.

The weird thing is when I press enter halfway through typing the name of my new class, instead of importing the class, it just inserts the entire package name.

i.e.:

MyObject object = new com.example.MyObject();

Has anybody experienced this before?

like image 398
Alex Crist Avatar asked Sep 03 '15 23:09

Alex Crist


People also ask

Can we change the package name in Android Studio?

Step by Step Implementation Step 2: Now click on the setting gear icon and deselect Compact Middle Packages. Step 3: Now the packages folder is broken into parts as shown in the below image. Step 4: Now right-click on the first package name (com) and Refactor > Rename.

Does package name matter Android studio?

It shouldn't matter. In case you still wish to change, you have to unpublish your app and publish it as a new app. This is because Google identifies your app through you bundle ID, or package name as it is called. So you cannot repeat 2 package names.


1 Answers

This happened to me recently. My solution was to uncheck the "Use fully qualified class names" option under File --> Settings --> Editor --> Code Style --> Java --> Imports (tab)

like image 120
moya Avatar answered Sep 24 '22 22:09

moya