Cannot resolve symbol 'IOUtils'
Solution 1
Right clicking on the commons-io-2.4.jar
file in project navigator and clicking 'Add to project' solved the issue.
Solution 2
For Android Studio:
- File -> Project Structure... -> Dependencies
- Click '+' in the upper right corner and select "Library dependency"
- In the search field type: "org.apache.commons.io" and click Search
- Select "org.apache.directory.studio:org.apache.commons.io:<X.X>
Or
Add implementation 'org.apache.directory.studio:org.apache.commons.io:2.4
to the build.gradle
file
Solution 3
Adding below dependency solved issue
implementation 'org.apache.directory.studio:org.apache.commons.io:2.4'
Solution 4
For those who encountered this while working on a Netbeans Java project. What I did is I downloaded the Binaries Zip of IO here
Commons IO Util Jar Download Here
Then Right clicked on my Project>Properties>
On the Categories Pane, Click Libraries
Then Click Add Jar/Folder
Locate the jar file/folder of the extracted IO Util that was downloaded.
Then click Ok. That fixed mine. :)
Harikrishnan
Wellversed in: PySpark iOS Application Development Android Application Development Windows UWP Development Electron Angular Hadoop Ecosystem AWS Programming Languages: Java Kotlin Python Javascript Swift Objective-C Love to: Read Travel(I am the one driving/Riding) Movies/Series Code Sleep Interests: Cars Motorcycles Gadgets New Technologies PS : Also loves to keep the above list ever expanding!!!
Updated on July 14, 2022Comments
-
Harikrishnan almost 2 years
I have used the following code to create a temporary file in my android app:
public File streamToFile (InputStream in) throws IOException { File tempFile = File.createTempFile("sample", ".tmp"); tempFile.deleteOnExit(); FileOutputStream out = new FileOutputStream(tempFile); IOUtils.copy(in, out); return tempFile; }
Now the problem is
Cannot resolve symbol 'IOUtils'
. I did a little bit of googling and discovered that for using IOUtils I need to download and include a jar file. I downloaded the jar file from here(commons-io-2.4-bin.zip). I added the jar namedcommons-io-2.4.jar
from the zip to my bundle and when I tried to import it using:import org.apache.commons.io.IOUtils;
It is showing error
Cannot resolve symbol 'io'
. So I tried to import it like:import org.apache.commons.*
But still I am getting the error
Cannot resolve symbol 'IOUtils'
.Question 1 : Why am I getting this error? How to resolve it?
Question 2 : Is there any way to create a temp file from an InputStream without using an external library? Or is this the most efficient way to do that? I am using android studio.
-
Joaquin Iurchuk over 8 yearsOr add
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
to thebuild.gradle
file -
CrandellWS about 8 years@Zindarod late answer I know but see stackoverflow.com/questions/17895557/… for obtaining jar
-
Tamás Bolvári almost 8 yearsTo see the Dependices tab, first click on "app" under "Modules".
-
Oleg over 6 yearsThe question is tagged with android-studio an answer about Netbeans doesn't answer it.
-
iamjoshua over 6 yearsandroid uses close to java syntax anyway.& I was searching for this exact problem that I encountered while working in netbeans that used to be an IDE for developing in android,seems to be worth pointing out. The Step by step problems and necessary jar files provided above for android-studio is close to what will solve the same problem above if encountered in Netbeans. I'm just providing my version of it in netbeans since this could be encountered while working in netbeans too. Fact is, I am working on this java proj.in netbeans so that I could deploy it in android later with working code.
-
dilanSachi about 5 yearssometimes android studio doesn't install the dependencies if we do as in the answer. its better to do it manually like @JoaquinIurchuk said