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

我想让我的项目使用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
        }
    }
}

我该如何解决这个错误?

最佳答案
找到了解决这个问题的方法.如果你去项目结构 – >模块 – > <您的项目> – > Android,你会注意到没有任何东西加载.它看起来像这样:

要解决此问题,请选择Android并单击“删除”(上面的红色虚线).然后单击添加(上面的绿色加号)并选择Android.单击确定,错误现在应该消失.

转载注明原文:Android Gradle构建中的意外节点Android Packaging - 代码日志