Android Studio gradle 2.1.3 issue

雨燕双飞 提交于 2019-12-29 08:39:11

问题


Gradle Issue in Android Studio 2.1.3

I got those errors when i run the Desktop application that i've created based on the Tutorial.


where i can find that Gradle 2.1.3? Please help me. Im using Libgdx framework. Thank you in advance.

Error:Gradle: A problem occurred configuring root project 'Flapp Bird'. Could not resolve all dependencies for configuration ':classpath'. Could not find com.android.tools.build:gradle:2.1.3. Searched in the following locations: file:/C:/Users/Unknown/.m2/repository/com/android/tools/build/gradle/2.1.3/gradle-2.1.3.pom file:/C:/Users/Unknown/.m2/repository/com/android/tools/build/gradle/2.1.3/gradle-2.1.3.jar

https:://repo1.maven.org/maven2/com/android/tools/build/gradle/2.1.3/gradle-2.1.3. https:://repo1.maven.org/maven2/com/android/tools/build/gradle/2.1.3/gradle-2.1.3.jar https:://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.1.3/gradle-2.1.3.pom https:://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.1.3/gradle-2.1.3.jar

Required by: :Flapp Bird:unspecified


回答1:


The Gradle version 2.1.3 exists, but is not in the Maven central, as said here.

To fix the issue, just add jcenter() after mavenCentral() in your build script.

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
    }
}



回答2:


No, Ivan is right. The latest version of Android Studio insists on upgrading to Android Plugin for Gradle, Revision 2.1.3 (August 2016), Gradle 2.14.1 or higher and Build Tools 23.0.2 or higher. But the moment it does that, it breaks compilation with that error:

Could not resolve all dependencies for configuration ':classpath'. Could not find com.android.tools.build:gradle:2.1.3. Searched in the following locations: 



回答3:


buildscript {
  repositories {
    mavenCentral()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle-experimental:0.7.3'
    classpath 'com.android.tools.build:gradle:2.1.3'
   }
}

For me adding this: classpath 'com.android.tools.build:gradle-experimental:0.7.3' did the trick.




回答4:


AFAIK, the latest version of Gradle is 2.1.2. You might be confusing the gradle version with the gradle plugin. A similar question to yours was also answered over here Just change 'com.android.tools.build:gradle:2.1.3' to 2.1.2and you should be set.



来源:https://stackoverflow.com/questions/39000831/android-studio-gradle-2-1-3-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!