Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Android Studio can't reference a library if included in build.gradle only?

In my app I'm using Guava library. I have referenced it in my build.gradle file only as follows:

dependencies {
    compile 'com.google.guava:guava:13.0.1'
 }

My app rebuilds and runs fine. However when I'm trying to add a new something from Guava library then the compiler complains that it can't find the class.

For example: when I write

import com.google.common.base.Preconditions

in my new file the compiler says 'cannot resolve symbol common'.

But my old files are rebuilt fine. How so? Do I have to mess with Project|Structure? I specifically wanted to list any dependencies -only- in build.gradle.

like image 333
Alexander Kulyakhtin Avatar asked Mar 23 '23 05:03

Alexander Kulyakhtin


1 Answers

It seems that doing a "sync project with gradle files" helps.

In Android Studio, select :

Tools > Android > Sync project with gradle files

like image 79
hrstrand Avatar answered Mar 25 '23 00:03

hrstrand