Gradle Build对于任务应用程序失败:processReleaseResources

时间:2016-02-15 10:54:25

标签: java android gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.nusecond.karun.suredeal"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
 signingConfigs {
        release {
            storeFile file("suredealreleasekey.keystore")
            storePassword "suredeal"
            keyAlias "SuredealReleaseKey"
            keyPassword "suredeal"
        }
    }


buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    packagingOptions {
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
    }
}
repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.facebook.android:facebook-android-sdk:4.6.0'
    testCompile 'com.android.support:support-annotations:23.1.1'
    androidTestCompile 'com.android.support:support-annotations:23.1.1'


    compile 'com.google.android.gms:play-services-base:8.4.0'
    compile 'com.google.android.gms:play-services-plus:8.4.0'
    compile 'com.google.android.gms:play-services-auth:8.4.0'
    compile 'com.android.support:support-v13:23.1.1'

    /**
     * GSON
     */
    compile 'com.google.code.gson:gson:2.4'

    // UI AutomatorTesting
    androidTestCompile 'com.android.support.test:runner:0.2'
    androidTestCompile 'com.android.support.test:rules:0.2'
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'

    /**
     * Spring Dependencies
     * compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
     * compile 'com.fasterxml.jackson.core:jackson-core:2.4.2'
     * compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.0'
     */
    compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'

    /**
     * Android Annotation Dependencies
     */
    compile 'org.glassfish.main:javax.annotation:4.0-b33'

    /**
     * Volley Jar
     */
    compile files('libs/volley.jar')
    compile 'com.mcxiaoke.volley:library:1.0.19'

    /**
     * GCM Dependency
     */
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    /**
     * Universal image Loader
     */
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile files('libs/urlimageviewhelper-1.0.4.jar')

    compile 'com.squareup.picasso:picasso:2.5.2'
}
repositories {
    maven {
        url 'http://repo.spring.io/milestone'
    }
}
  1. 这是build.gradle
  2. 这里我使用Gradle Build生成签名的APK。(./gradlew assembleRelease)。 3.Build任务应用程序失败:processReleaseResources。
  3. 这里的堆栈跟踪:

    ----------
    ./gradlew assembleRelease --stacktrace
    :app:preBuild UP-TO-DATE
    :app:preReleaseBuild UP-TO-DATE
    :app:checkReleaseManifest
    :app:preDebugBuild UP-TO-DATE
    :app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
    :app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
    :app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
    :app:prepareComAndroidSupportSupportV132311Library UP-TO-DATE
    :app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
    :app:prepareComFacebookAndroidFacebookAndroidSdk460Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesAppindexing840Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesAuth840Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesBase840Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesBasement840Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesGcm840Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesMeasurement840Library UP-TO-DATE
    :app:prepareComGoogleAndroidGmsPlayServicesPlus840Library UP-TO-DATE
    :app:prepareReleaseDependencies
    :app:compileReleaseAidl UP-TO-DATE
    :app:compileReleaseRenderscript UP-TO-DATE
    :app:generateReleaseBuildConfig UP-TO-DATE
    :app:generateReleaseAssets UP-TO-DATE
    :app:mergeReleaseAssets UP-TO-DATE
    :app:generateReleaseResValues UP-TO-DATE
    :app:generateReleaseResources UP-TO-DATE
    :app:mergeReleaseResources UP-TO-DATE
    :app:processReleaseManifest UP-TO-DATE
    :app:processReleaseResources FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:processReleaseResources'.
    > at index 4
    
    * Try:
    Run with --info or --debug option to get more log output.
    
    * Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processReleaseResources'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
    Caused by: java.lang.NullPointerException: at index 4
        at com.google.common.collect.ObjectArrays.checkElementNotNull(ObjectArrays.java:240)
        at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:231)
        at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:226)
        at com.google.common.collect.ImmutableList.construct(ImmutableList.java:303)
        at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258)
        at com.android.ide.common.process.ProcessInfoBuilder.createProcess(ProcessInfoBuilder.java:55)
        at com.android.builder.core.AaptPackageProcessBuilder.build(AaptPackageProcessBuilder.java:444)
        at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:915)
        at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:138)
        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:98)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:243)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:230)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 49 more
    
    
    BUILD FAILED
    
    Total time: 6.696 secs
    

    我被困在这里任何解决方案如何解决这个问题PLZ帮助我。

8 个答案:

答案 0 :(得分:5)

最后,经过这么多文章,我得到了解决这个问题的方法。

此问题是因为s​​dk工具版本不匹配。

build.gradle文件中的目标sdk版本必须与您安装的sdk版本匹配。

答案 1 :(得分:1)

我的解决方案来自这里

从不需要的RES / DRAW中删除所有图像

https://github.com/facebook/react-native/issues/19239

-> ZeroCool00的信用

对于那些在生成apk之前正在执行此操作的人

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android / app / src / main / assets / index.android.bundle --assets-dest android / app / src / main / res

它在可绘制文件夹中生成不必要的可绘制图像。因此请确保将其删除,然后重试。

android-> app-> src-> main-> res-> drawable

答案 2 :(得分:0)

在build.gradle中,

applicationId "com.company.app"

应该在AndroidManifest.xml中匹配:

package="com.company.app"

我得到了同样的错误,因为它们不匹配。

答案 3 :(得分:0)

在我的情况下,它是资产

中文件的长(超过100个字符)

答案 4 :(得分:0)

  

经过大量搜索,我找到了解决方案

android / gradle.properties 中 加 android.enableAapt2=false

答案 5 :(得分:0)

我的方法总是尝试最简单的潜在解决方案:我在app文件夹的gradle.properties中添加了这一行:

android.enableAapt2=false

它很好奇,没问题。

答案 6 :(得分:0)

用于cordova项目

添加cordova插件cordova-android-support-gradle-release为我解决了此问题。

答案 7 :(得分:0)

对我来说,问题是由xml文件中的循环引用引起的。除非明确指示,否则皮棉通常会标出问题所在。 检查:

tools:ignore="ResourceCycle"