Android Gradle构建中的意外节点Android Packaging

时间:2014-11-13 14:02:29

标签: android intellij-idea gradle android-gradle build.gradle

我正在尝试使用gradle。问题是每次我尝试构建时,都会出现以下错误:

Error:Internal error: (java.lang.AssertionError) Unexpected node Android Packaging; nodes=[Module 'Serengeti' production, Resources for 'Serengeti' production, Resources for 'Serengeti' tests, Artifact 'Serengeti', gradle-resources-production:Serengeti, gradle-resources-test:Serengeti, Android Gradle Build Target]
java.lang.AssertionError: Unexpected node Android Packaging; nodes=[Module 'Serengeti' production, Resources for 'Serengeti' production, Resources for 'Serengeti' tests, Artifact 'Serengeti', gradle-resources-production:Serengeti, gradle-resources-test:Serengeti, Android Gradle Build Target]
    at com.intellij.util.graph.GraphGenerator.buildOuts(GraphGenerator.java:55)
    at com.intellij.util.graph.GraphGenerator.<init>(GraphGenerator.java:36)
    at com.intellij.util.graph.GraphGenerator.create(GraphGenerator.java:40)
    at org.jetbrains.jps.builders.impl.BuildTargetIndexImpl.initializeChunks(BuildTargetIndexImpl.java:86)
    at org.jetbrains.jps.builders.impl.BuildTargetIndexImpl.getSortedTargetChunks(BuildTargetIndexImpl.java:50)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:610)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:352)
    at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:191)
    at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:131)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:229)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:113)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:158)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

我不知道这意味着什么。我找到了this,但它并没有真正帮助......

这是我的build.gradle文件。这是我第一次使用gradle,所以如果有任何问题请指出。

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/repo' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.14.+'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'android'
apply plugin: 'io.fabric'

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/repo' }
}

dependencies {
    // http://gradleplease.appspot.com/
    compile 'com.android.support:support-v4:20.+'
    compile 'com.google.android.gms:play-services:+'
    compile 'joda-time:joda-time:+'
    compile 'com.googlecode.android-query:android-query:+'
    compile 'me.dm7.barcodescanner:zbar:+'
    compile 'com.github.asne.facebook:facebook:3.17.2'
    compile('com.twitter.sdk.android:twitter:1.0.1@aar') {
        transitive = true;
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
    }
    lintOptions {
        abortOnError false
    }
    signingConfigs {
        SignConfig {
            keyAlias 'removed'
            keyPassword 'removed'
            storeFile file('removed')
            storePassword 'removed'
        }
    }
    buildTypes {
        debug {
            sourceSets {
                main {
                    manifest.srcFile 'AndroidManifest.xml'
                    java.srcDirs = ['src']
                    resources.srcDirs = ['src']
                    aidl.srcDirs = ['src']
                    renderscript.srcDirs = ['src']
                    res.srcDirs = ['res']
                    assets.srcDirs = ['assets']
                }
            }
        }

        release {
            zipAlignEnabled
            sourceSets {
                main {
                    manifest.srcFile 'AndroidManifest.xml'
                    java.srcDirs = ['src']
                    resources.srcDirs = ['src']
                    aidl.srcDirs = ['src']
                    renderscript.srcDirs = ['src']
                    res.srcDirs = ['res']
                    assets.srcDirs = ['assets']
                }
            }
        }
    }
    productFlavors {
        RunConfig {
            signingConfig signingConfigs.SignConfig
        }
    }
}

如何修复此错误?

1 个答案:

答案 0 :(得分:10)

找到解决此问题的方法。如果您转到项目结构 - &gt; 模块 - &gt; <Your project> - &gt; Android ,您会发现没有任何内容加载。它看起来像这样:

enter image description here

要解决此问题,请选择 Android ,然后点击删除(上面的红色短划线)。然后点击添加(上面的绿色加号)并选择 Android 。点击确定,错误现在就消失了。