如何解决gradle构建过程的资源问题?

时间:2016-09-26 06:40:52

标签: android gradle build.gradle android-gradle-2.0

我正在尝试构建我的Android应用程序但是我收到以下错误:

Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/appcompat-v7/24.2.1/appcompat-v7-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/appcompat-v7/24.2.1/appcompat-v7-24.2.1.jar]
Cached resource https://jcenter.bintray.com/com/appdynamics/appdynamics-runtime/4.2.6.0/appdynamics-runtime-4.2.6.0.pom is up-to-date (lastModified: Fri Sep 09 23:53:16 BDT 2016).
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/support-v4/24.2.1/support-v4-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/support-v4/24.2.1/support-v4-24.2.1.aar]
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/support-vector-drawable/24.2.1/support-vector-drawable-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/support-vector-drawable/24.2.1/support-vector-drawable-24.2.1.aar]
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/animated-vector-drawable/24.2.1/animated-vector-drawable-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/animated-vector-drawable/24.2.1/animated-vector-drawable-24.2.1.aar]
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/support-compat/24.2.1/support-compat-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/support-compat/24.2.1/support-compat-24.2.1.aar]
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/support-media-compat/24.2.1/support-media-compat-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/support-media-compat/24.2.1/support-media-compat-24.2.1.aar]
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/support-core-utils/24.2.1/support-core-utils-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/support-core-utils/24.2.1/support-core-utils-24.2.1.aar]
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/support-core-ui/24.2.1/support-core-ui-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/support-core-ui/24.2.1/support-core-ui-24.2.1.aar]
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/support-fragment/24.2.1/support-fragment-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/support-fragment/24.2.1/support-fragment-24.2.1.aar]
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/android/support/support-annotations/24.2.1/support-annotations-24.2.1.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/android/support/support-annotations/24.2.1/support-annotations-24.2.1.jar]
Cached resource https://jcenter.bintray.com/com/appdynamics/appdynamics-runtime/4.2.6.0/appdynamics-runtime-4.2.6.0.jar is up-to-date (lastModified: Fri Sep 09 23:52:32 BDT 2016).
Using incremental javac compilation.
Incremental java compilation is an incubating feature.
Cached resource https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom  is up-to-date (lastModified: Thu Dec 04 22:17:00 BDT 2014).
Cached resource https://jcenter.bintray.com/org/hamcrest/hamcrest- core/1.3/hamcrest-core-1.3.pom is up-to-date (lastModified: Tue Jul 10 03:08:02 BDT 2012).
Cached resource https://jcenter.bintray.com/org/hamcrest/hamcrest-parent/1.3/hamcrest-parent-1.3.pom is up-to-date (lastModified: Tue Jul 10 03:06:57 BDT 2012).
Cached resource https://jcenter.bintray.com/org/hamcrest/hamcrest-parent/1.3/hamcrest-parent-1.3.pom is up-to-date (lastModified: Tue Jul 10 03:06:57 BDT 2012).
Cached resource https://jcenter.bintray.com/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar is up-to-date (lastModified: Tue Jul 10 03:08:02 BDT 2012).
Cached resource https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.jar is up-to-date (lastModified: Thu Dec 04 22:17:00 BDT 2014).
Using incremental javac compilation.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
>  org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection  cannot be cast to   org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Tota l time: 1 mins 34.258 secs
Stopped 0 compiler daemon(s).
Received result Failure[value=org.gradle.initialization.ReportedException:  org.gradle.internal.exceptions.LocationAwareException: A problem occurred  configuring project ':app'.] from
 daemon DaemonInfo{pid=1064, address=[9a781baa-2c2c-4e92-ad0c-0bbdb5197835  port:10948, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]], idle=true,  lastBusy=1474870787112, context=DefaultDa
emonContext[uid=ad87762a-a999-4f43-98b4- 3d571971ffb2,javaHome=D:\Adit\jre,daemonRegistryDir=C:\Users\Adit\.gradle\daemon ,pid=1064,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m
,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252,-  Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).

我的build.gradle文件是:

apply plugin: 'com.android.application'
apply plugin: 'adeum' // this line added for AppDynamics
android {
  compileSdkVersion 24
  buildToolsVersion "24.0.2"

defaultConfig {
    applicationId "com.example.adit.myapplication3"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
 }
}

dependencies {

 compile fileTree(dir: 'libs', include: ['*.jar'])
 testCompile 'junit:junit:4.12'
 compile 'com.android.support:appcompat-v7:24.2.1'
 compile 'com.appdynamics:appdynamics-runtime:4.+' // this line added for   AppDynamics
}

adeum { // this section added for AppDynamics
   account {
    name '281215-ss-Ogilvy-net8du5zsh4i'
    licenseKey 'You must request this key from an Admin.'
}
proguardMappingFileUpload {
    failBuildOnUploadFailure true //should build fail if upload fails? Defaults to false.
    enabled true //enables automatic uploads. Defaults to true.
  }
}

我的顶级build.gradle文件是:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    maven {url uri("adeum-maven-repo") } //this line added for AppDynamics
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.3'

    classpath 'com.appdynamics:appdynamics-gradle-plugin:4.+' // this line added for AppDynamics

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

allprojects {
 repositories {
    jcenter()
    maven {url uri("adeum-maven-repo") } //this line added for AppDynamics
 }
}

我认为由于缺少资源,我的构建失败了。我该如何解决这个问题?我正在尝试使用我的Android应用程序。

1 个答案:

答案 0 :(得分:0)

转到项目级build.gradle文件,并添加以下代码中缺少的代码:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.gms:google-services:2.0.0'

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

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

task clean(type: Delete) {
    delete rootProject.buildDir
}