简体   繁体   中英

Android Studio Gradle 3.0 error when compiling java project

before updating to AS and Gradle 3.0, I had created a separate java module in my android project to run tests. It had its own build.gradle and run configurations. It used to work perfectly until I upgraded to gradle 3. Now, when I try to compile it gives me the following error :

 Error:Gradle: A problem occurred configuring root project 'RUN'.
 Could not resolve all files for configuration ':classpath'.
   Could not find com.android.tools.build:gradle:3.0.0.
 Searched in the following locations:
     https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
     https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
     http://dl.bintray.com/sergiocasero/maven/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
     http://dl.bintray.com/sergiocasero/maven/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
 Required by:
     project :

The build.gradle file for the module is the following :

apply plugin: 'application'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'joda-time:joda-time:2.9.4'
    compile 'commons-validator:commons-validator:1.6'
}

sourceCompatibility = "1.7"
targetCompatibility = "1.7"

This file was created using the AS wizard.

I do not understand why gradle is looking for the android build tools when building a java project. Anyone have any idea how I can get my module to compile? Thanks.

If the project has 1+ Android modules, the classpath request to load the Android Plugin for Gradle will be in the project-level build.gradle file, and the contents of that file is used even for non-Android modules.

If you add google() to both repositories closure, you will be able to load this plugin. As a side benefit, you will also be able to start using the newer versions of the various Google libraries in your Android modules (eg, com.android.support artifacts), which also come from Google's Maven repo.

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