Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio auto fix

I don't know what the exact name is for s feature like this, but I will just describe it.

I am using android studio and I added some java classes from a different project. Now it says

"missing package statement: yada yada". But there is not option in the error popup to just automatically add the missing package statement. I know it seems lazy to not type it, but I like to do things quickly.

When there is an error like this, is there a way for android studio to automatically added the needed lines of code like eclipse would?

like image 777
Scorb Avatar asked Feb 21 '14 21:02

Scorb


People also ask

Why is auto complete not working in Android Studio?

if the autocomplete isn't working for you in Android Studio, just press File and uncheck the Power save mode, it should work fine after that. if power save mode is already unchecked then first check then uncheck them.

What is lint Android studio?

The lint tool checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization. When using Android Studio, configured lint and IDE inspections run whenever you build your app.

How do you calculate lint error?

Configuring lint checking in Java and XML source files Tip: If you are using Android Studio, you can use the File > Settings > Project Settings > Inspections feature to manage the lint checking to your Java or XML source files.


1 Answers

This is a common frustration. While not a perfect solution, I found https://stackoverflow.com/a/16616085/967131 to work for me.

For Windows/Linux, you can go to File -> Settings -> Editor -> General -> Auto Import -> Java and make the following changes:

change "Insert imports on paste" dropdown value to "All"

check "Add unambiguous imports on the fly" option

On a Mac, do the same thing in Android Studio -> Preferences

That way, as you type, or when you copy and paste, many imports will be added automatically. Those that aren't are ambiguous; put the cursor on the class, press alt+enter and select which version of the class you meant.

like image 159
Chad Schultz Avatar answered Jan 08 '23 08:01

Chad Schultz