简体   繁体   English

Android Studio找不到导入的库

[英]Android Studio can't find imported library

I've imported a library in Android studio (0.5.3) 我在Android工作室导入了一个库(0.5.3)

My settings.graddle looks like this: 我的settings.graddle看起来像这样:

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

And my build.graddle looks like this: 我的build.graddle看起来像这样:

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. 我下载的文件夹放在app文件夹下的libs文件夹中。 Also the graddle syncs and building doesn't provide any error. 同时,graddle同步和构建不会提供任何错误。 Yet whenever I try to import import com.handmark.xxxxxx; 然而,每当我尝试导入import com.handmark.xxxxxx; I get the error cannot resolve symbol 'handmark' . 我得到错误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. 我在这里遇到了同样的问题并在“Android开发者工具”Google +社区上提出了问题 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. 然后在工作室中重新编译你的项目,你应该看到你的新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. 我有与此完全相同的问题,但是库文件是一个aar文件,并且在添加库并使用它开发一段时间后发生了很长时间。

Building on the information Thomas provided ; 托马斯 提供的信息为基础 ; I found to fix this you should replace the file dependency with a maven dependency if possible. 我找到了解决这个问题,你应该尽可能用maven依赖替换文件依赖。 A good resource for finding and creating your Gradle dependency is Gradle, please . 寻找和创建摇篮依赖一个很好的资源是摇篮,请

That site returns the below dependency when searching for PullToRefresh 在搜索PullToRefresh时,该站点返回以下依赖PullToRefresh

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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