简体   繁体   中英

Android Studio can't find imported library

I've imported a library in Android studio (0.5.3)

My settings.graddle looks like this:

include ':app', ':libs:Android-PullToRefresh-master'

And my build.graddle looks like this:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.1'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'com.android.support:support-v4:19.+'
    compile 'com.google.android.gms:play-services:4.2.42'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    project(':libs:Android-PullToRefresh-master');
}

The folder I've downloaded is placed in the libs folder directly under the app folder. Also the graddle syncs and building doesn't provide any error. Yet whenever I try to import import com.handmark.xxxxxx; I get the error cannot resolve symbol 'handmark' . I've chcecked to project structure and the app has the dependency in the list.

What is going wrong and how can I fix this?

I ran into the same issue here and asked the question on the "Android Developer Tools" Google+'s community. Alex Ruiz picked up the conversation and told me:

I'm able to reproduce this issue. Unfortunately, no updates yet. We are currently fixing the "Project Structure" (the core infrastructure,) and we will get to this, hopefully soon.

So they are aware of it but we still have to wait until they fix it.

In the root of your project, run :

./gradlew clean && ./gradlew build

Then recompile your project in studio and you should see your new lib.

I had the exact same problem as this, however the library file was an aar file, and it happened a long time after adding the library and developing with it for a while.

Building on the information Thomas provided ; I found to fix this you should replace the file dependency with a maven dependency if possible. A good resource for finding and creating your Gradle dependency is Gradle, please .

That site returns the below dependency when searching for PullToRefresh

dependencies {
    compile 'com.loopeer.android.thirdparty.pulltorefresh:Android-PullToRefresh:2.1.1'
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM