I'm importing twitter4j in AndroidStudio, using the following in my build.gradle:
dependencies { compile 'com.android.support:support-v4:18.0.+' compile files('libs/twitter4j-core-3.0.4.jar') }
The project compiles fine, and I can create twitter objects without a problem. However, in Android studio, anything referencing that library shows "cannot resolve symbol" and displays in red. What do I need to do to get Android Studio to recognize the library?
I have already tried rebuilding the project, ./gradlew clean, and closing and re-opening my project.
In JavaLanguage, if you get 'cannot resolve symbol', you have used a name that the compiler hasn't recognized. Class names -- If it is a class name, the compiler cannot find the class.
First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.
No idea if this will work or not but my only thought so far: right click the jar file in file tree within AS and select "Add as library..."
EDIT: You can do "File" -> "Invalidate Caches...", and select "Invalidate and Restart" option to fix this.
EDIT 2: This fix should work for all similar incidents and is not a twitter4j specific resolution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With