简体   繁体   English

Gradle找不到依赖项-Android Studio

[英]Gradle doesn't find dependency - Android Studio

Gradle no longer finds dependencies declared in the build.gradle. Gradle不再找到在build.gradle中声明的依赖项。 Everything was working fine and today when I open Android Studio I get an error : 一切运行正常,今天打开Android Studio时出现错误:

 Error:Failed to find: com.readystatesoftware.systembartint:systembartint:1.0.3

The library referenced is SystemBarTint . 引用的库是SystemBarTint I had the library work previously using the same build.gradle file but now it no longer works. 我以前使用相同的build.gradle文件使库工作,但现在不再起作用。

My app/build.gradle looks like this : 我的app / build.gradle看起来像这样:

 apply plugin: 'com.android.application'

 android {
     compileSdkVersion 19
     buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.example.adnan.systembartintdemo"
        minSdkVersion 19
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
 }

 dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])

     compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
}

My root/build.gradle looks like this : 我的root / build.gradle看起来像这样:

  buildscript {
          repositories {
                jcenter()
                mavenCentral()
          }

          dependencies {
                 classpath 'com.android.tools.build:gradle:0.12.+'

            // NOTE: Do not place your application dependencies here; they belong
           // in the individual module build.gradle files
          }
}

 allprojects {
      repositories {
            jcenter()
            mavenCentral()
      }
}

Any ideas what I am doing wrong here? 有什么想法我在这里做错了吗? Thanks ! 谢谢 !

Edit : Tried importing a project which I work on daily at my work, it fails to find any dependencies in that project either. 编辑:试图导入一个我每天在工作的项目,它也找不到该项目中的任何依赖项。 Tried re installing Android Studio, still the same error 尝试重新安装Android Studio,仍然出现相同的错误

Ok finally got this fixed.The problem was weird, for some reason it was trying to pick up a local offline copy of the dependency, I went to Settings -> Compiler -> Gradle -> Enabled offline Work and disabled it again. 好的终于解决了。问题很奇怪,由于某种原因,它试图获取依赖项的本地脱机副本,我去了设置->编译器-> Gradle->启用离线工作并再次禁用它。 Save and Apply changes . 保存并应用更改

And now it works ! 现在就可以了!

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

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