Alexander
Alexander

Reputation: 48272

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.

Upvotes: 4

Views: 3463

Answers (1)

hrstrand
hrstrand

Reputation: 94

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

In Android Studio, select :

Tools > Android > Sync project with gradle files

Upvotes: 7

Related Questions