35

我在使用 Gradle 和 Android Studio 时遇到了很多问题。

对项目中的任何资源进行更改都会在编译期间随机给出异常,这是我在 Android Studio 中看到的:

Gradle: Error while executing aapt command
Gradle: Execution failed for task ':App Code:processReleaseResources'.

这就是我看到手动执行 Gradle 的内容:

"/Applications/Android Studio.app/sdk/tools/templates/gradle/wrapper/gradlew" asD
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:App Code:preBuild UP-TO-DATE                                 
:App Code:preDebugBuild UP-TO-DATE  
:App Code:preReleaseBuild UP-TO-DATE  
:libraries:facebook:compileLint             
:libraries:facebook:copyReleaseLint UP-TO-DATE  
:libraries:facebook:mergeReleaseProguardFiles UP-TO-DATE  
:libraries:facebook:packageReleaseAidl UP-TO-DATE  
:libraries:facebook:preBuild UP-TO-DATE  
:libraries:facebook:preReleaseBuild UP-TO-DATE  
:libraries:facebook:prepareReleaseDependencies             
:libraries:facebook:compileReleaseAidl UP-TO-DATE  
:libraries:facebook:compileReleaseRenderscript UP-TO-DATE  
:libraries:facebook:generateReleaseBuildConfig UP-TO-DATE  
:libraries:facebook:mergeReleaseAssets UP-TO-DATE  
:libraries:facebook:mergeReleaseResources UP-TO-DATE  
:libraries:facebook:processReleaseManifest UP-TO-DATE  
:libraries:facebook:processReleaseResources UP-TO-DATE  
:libraries:facebook:generateReleaseSources UP-TO-DATE  
:libraries:facebook:compileRelease UP-TO-DATE  
:libraries:facebook:processReleaseJavaRes UP-TO-DATE  
:libraries:facebook:packageReleaseJar UP-TO-DATE  
:libraries:facebook:packageReleaseLocalJar UP-TO-DATE  
:libraries:facebook:packageReleaseRenderscript UP-TO-DATE  
:libraries:facebook:packageReleaseResources UP-TO-DATE  
:libraries:facebook:bundleRelease UP-TO-DATE  
:App Code:prepareComAndroidSupportAppcompatV71800Library UP-TO-DATE  
:App Code:prepareComGoogleAndroidGmsPlayServices3136Library UP-TO-DATE  
:App Code:prepareLatestUpdateLibrariesFacebookUnspecifiedLibrary UP-TO-DATE  
:App Code:prepareDebugDependencies             
:App Code:compileDebugAidl             
:App Code:compileDebugRenderscript             
:App Code:generateDebugBuildConfig             
:App Code:mergeDebugAssets             
:App Code:mergeDebugResources             
:App Code:processDebugManifest             
:App Code:processDebugResources FAILED      

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':App Code:processDebugResources'.
> Failed to run command:
        /Applications/Android Studio.app/sdk/build-tools/android-4.2.2/aapt package -f --no-crunch -I /Applications/Android Studio.app/sdk/platforms/android-17/android.jar -M /Users/oslinux/Documents/workspace/Appme-android/latest-update/App Code/build/manifests/debug/AndroidManifest.xml -S /Users/oslinux/Documents/workspace/Appme-android/latest-update/App Code/build/res/all/debug -A /Users/oslinux/Documents/workspace/Appme-android/latest-update/App Code/build/assets/debug -m -J /Users/oslinux/Documents/workspace/Appme-android/latest-update/App Code/build/source/r/debug -F /Users/oslinux/Documents/workspace/Appme-android/latest-update/App Code/build/libs/App Code-debug.ap_ --debug-mode --custom-package com.floaty.App --output-text-symbols /Users/oslinux/Documents/workspace/Appme-android/latest-update/App Code/build/symbols/debug
  Error Code:
        139


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

BUILD FAILED

Total time: 20.268 secs
host-005:App Code oslinux$ 

使用--stacktrace执行 Gradle这是输出异常:

 * Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':VMS Code:processDebugResources'.
        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.changedetection.state.CacheLockReleasingTaskExecuter$1.run(CacheLockReleasingTaskExecuter.java:35)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:179)
        at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:232)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:142)
        at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:83)
        at org.gradle.api.internal.changedetection.state.CacheLockReleasingTaskExecuter.execute(CacheLockReleasingTaskExecuter.java:33)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.ContextualisingTaskExecuter.execute(ContextualisingTaskExecuter.java:34)
        at org.gradle.api.internal.changedetection.state.CacheLockAcquiringTaskExecuter$1.run(CacheLockAcquiringTaskExecuter.java:39)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
        at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
        at org.gradle.api.internal.changedetection.state.CacheLockAcquiringTaskExecuter.execute(CacheLockAcquiringTaskExecuter.java:37)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:282)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.executeTask(DefaultTaskPlanExecutor.java:48)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.processTask(DefaultTaskPlanExecutor.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:27)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:89)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
        at org.gradle.api.internal.changedetection.state.TaskCacheLockHandlingBuildExecuter$1.run(TaskCacheLockHandlingBuildExecuter.java:31)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:124)
        at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:112)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:134)
        at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.useCache(DefaultTaskArtifactStateCacheAccess.java:79)
        at org.gradle.api.internal.changedetection.state.TaskCacheLockHandlingBuildExecuter.execute(TaskCacheLockHandlingBuildExecuter.java:29)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
        at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
        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:48)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.Main.main(Main.java:39)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
        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: com.android.ide.common.internal.LoggedErrorException: Failed to run command:
        /Applications/Android Studio.app/sdk/build-tools/android-4.2.2/aapt package -f --no-crunch -I /Applications/Android Studio.app/sdk/platforms/android-17/android.jar -M /Users/oslinux/Documents/workspace/vmsme-android/latest-update/VMS Code/build/manifests/debug/AndroidManifest.xml -S /Users/oslinux/Documents/workspace/vmsme-android/latest-update/VMS Code/build/res/all/debug -A /Users/oslinux/Documents/workspace/vmsme-android/latest-update/VMS Code/build/assets/debug -m -J /Users/oslinux/Documents/workspace/vmsme-android/latest-update/VMS Code/build/source/r/debug -F /Users/oslinux/Documents/workspace/vmsme-android/latest-update/VMS Code/build/libs/VMS Code-debug.ap_ --debug-mode --custom-package com.floaty.vms --output-text-symbols /Users/oslinux/Documents/workspace/vmsme-android/latest-update/VMS Code/build/symbols/debug
Error Code:
        139

        at com.android.ide.common.internal.CommandLineRunner.runCmdLine(CommandLineRunner.java:98)
        at com.android.ide.common.internal.CommandLineRunner.runCmdLine(CommandLineRunner.java:69)
        at com.android.builder.AndroidBuilder.processResources(AndroidBuilder.java:617)
        at com.android.builder.AndroidBuilder$processResources.call(Unknown Source)
        at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.groovy:91)
        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.groovy:71)
        at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:216)
        at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:122)
        at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
        at com.android.build.gradle.tasks.ProcessAndroidResources_Decorated.invokeMethod(Unknown Source)
        at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:217)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:199)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:526)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:509)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 70 more


BUILD FAILED

Total time: 14.276 secs
host-005:VMS Code oslinux$ 

我正在使用 Android Studio 0.2.13

我该如何解决这些问题?

编辑:这是我的 build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
        classpath 'com.newrelic.agent.android:agent-gradle-plugin:2.397.0'
    }
}

repositories {
    mavenCentral()
    maven {
        url 'http://www.bugsense.com/gradle/'
    }
}

apply plugin: 'android'
apply plugin: 'newrelic'

dependencies {
    compile 'com.newrelic.agent.android:android-agent:2.397'
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.android.support:appcompat-v7:18.0.+'
    compile 'com.intellij:annotations:12.+'
    compile 'com.bugsense.trace:bugsense:3.5'
    compile 'com.google.android.gms:play-services:3.1.+'
    compile 'net.hockeyapp.android:HockeySDK:3.0.+'
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':libraries:facebook')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 17
    }

    signingConfigs {
        release {
            storeFile file("/Users/oslinux/Documents/Chiavi Android/Sv01")
            storePassword "******"
            keyAlias "sv01"
            keyPassword "******"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            debuggable true
            jniDebugBuild false
        }
    }
}

更新

我尝试手动执行 aapt,从 gradle 吐出的错误消息中获取完整命令,它失败了:

Segmentation fault: 11

但有时它会正确运行并创建包。

除了“Segmentation fault: 11”之外,没有显示任何错误。

这是我要执行的命令:

"/Applications/Android Studio.app/sdk/build-tools/android-4.2.2/aapt" 
package -vv -f -a --no-crunch 
-I "/Applications/Android Studio.app/sdk/platforms/android-17/android.jar" 
-M "/Users/oslinux/Documents/workspace/app-android/latest-update/App Code/build/manifests/release/AndroidManifest.xml" 
-S "/Users/oslinux/Documents/workspace/app-android/latest-update/App Code/build/res/all/release" 
-A "/Users/oslinux/Documents/workspace/app-android/latest-update/App Code/build/assets/release" 
-m -J "/Users/oslinux/Documents/workspace/app-android/latest-update/App Code/build/source/r/release" 
-F "/Users/oslinux/Documents/workspace/app-android/latest-update/App Code/build/libs/App Code-release.ap_" 
--debug-mode --custom-package com.appandroid.app 
--output-text-symbols "/Users/oslinux/Documents/workspace/app-android/latest-update/App Code/build/symbols/release"

最后更新

似乎我终于解决了这个问题,清理了我的资源,删除了一些未使用的 XML 和未使用的主题。这显然不能回答我认为共同感兴趣的这个问题。

浏览网页时,我发现 AAPT 会因 SegFault11 而失败,而且它通常不会提供任何有关可能由以下原因引起的真正错误的信息:

  • 样式中的 +id
  • 重复的资源/库
  • 未知,和我一样

因此,这将是有用的: 1. 找到一种方法来确定此错误的真正原因 2. 等待返回一些错误消息的 AAPT 更新 3. 列出可能的常见原因。

4

12 回答 12

23

我在这里复制我的最终更新作为答案。

似乎我终于解决了这个问题,清理了我的资源,删除了一些未使用的 XML 和未使用的主题。这显然不能回答我认为共同感兴趣的这个问题。

浏览网页时,我发现 AAPT 会因 SegFault11 而失败,而且它通常不会提供任何有关可能由以下原因引起的真正错误的信息:

正如Dale Cooper 建议的那样,您也可以尝试运行 Lint 并查看它是否发现任何有关资源的警告。

我正在尝试查找遇到这些其他原因的用户的链接(自从最初的问题以来已经有一段时间了),当我找到他们时我会更新这个答案。

于 2013-12-12T16:47:37.363 回答
12

我只是遇到了同样的问题,但是在processDebugResources步骤上。几个小时后,我开始尝试运行aapt(/build-tools/[version]/aapt) 的不同版本,结果发现它们给出了一大堆不同的错误消息。我最初使用的19.0.1那个只是给了我Segmentation fault,但是当我尝试时,18.1.1我突然指向 a 中的一条线,该线menu.xml有资源不匹配。问题原来是我删除了默认值@string/action_settings,因为我认为我没有使用它。

结论,尝试不同版本的aapt可能会帮助您找到资源不匹配。

于 2014-01-02T01:14:53.027 回答
5

是的,我只是在为类似的问题而苦苦挣扎。原来我在 menu.xml 文件中有一些未完成的代码:

   <item android:id="@+id/action_search"
    android:title="@string/action_search"
    android:icon="@drawable/"
    app:showAsAction="ifRoom|collapseActionView"
    />

正是这条线缺少可绘制参考:

 android:icon="@drawable/"

我通过运行 Lint (Analyze -> Inspect code) 找到了它,它在 Android -> Android Resource Validation 中为Cannot resolve symbol '@drawable/'

于 2014-03-09T14:43:19.677 回答
4

我有同样的问题,很难找到它。

我想分享我为定位和解决这个问题所做的步骤。

我的 gradle 输出如下所示:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libs:base:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /opt/android-sdk/build-tools/18.1.1/aapt package -f --no-crunch -I /opt/android-sdk/platforms/android-19/android.jar -M /home/m039/WorkProjects/libs/base/build/bundles/debug/AndroidManifest.xml -S /home/m039/WorkProjects/libs/base/build/res/all/debug -A /home/m039/WorkProjects/libs/base/build/bundles/debug/assets -m -J /home/m039/WorkProjects/libs/base/build/source/r/debug -F /home/m039/WorkProjects/libs/base/build/libs/base-debug.ap_ --debug-mode --non-constant-id --output-text-symbols /home/m039/WorkProjects/libs/base/build/bundles/debug
  Error Code:
    139

首先我切换到 18.1.1 版本,并没有太大帮助。然后我尝试添加-v标志并运行以下命令:

/opt/android-sdk/build-tools/18.1.1/aapt package -f --no-crunch -I /opt/android-sdk/platforms/android-19/android.jar -M /home/m039/WorkProjects/libs/base/build/bundles/debug/AndroidManifest.xml -S /home/m039/WorkProjects/libs/base/build/res/all/debug -A /home/m039/WorkProjects/libs/base/build/bundles/debug/assets -m -J /home/m039/WorkProjects/libs/base/build/source/r/debug -F /home/m039/WorkProjects/libs/base/build/libs/base-debug.ap_ --debug-mode --non-constant-id --output-text-symbols /home/m039/WorkProjects/libs/base/build/bundles/debug -v

它有一点帮助,但没有给出有关问题的线索。然后我尝试strace了,它有很大帮助:

strace -s 100 /opt/android-sdk/build-tools/18.1.1/aapt package -f --no-crunch -I /opt/android-sdk/platforms/android-19/android.jar -M /home/m039/WorkProjects/libs/base/build/bundles/debug/AndroidManifest.xml -S /home/m039/WorkProjects/libs/base/build/res/all/debug -A /home/m039/WorkProjects/libs/base/build/bundles/debug/assets -m -J /home/m039/WorkProjects/libs/base/build/source/r/debug -F /home/m039/WorkProjects/libs/base/build/libs/base-debug.ap_ --debug-mode --non-constant-id --output-text-symbols /home/m039/WorkProjects/libs/base/build/bundles/debug 

在上一个命令的输出中,我发现了这一行:

open("/home/m039/WorkProjects/libs/base/build/res/all/debug/values/values.xml", O_RDONLY|O_LARGEFILE) = 5

values.xml文件中我找到了所有资源,然后我开始从文件末尾逐个标签删除并执行aapt上面的命令,直到发现问题。

我的问题出在 id 资源中。

于 2014-01-20T16:52:53.373 回答
2

导入eclipse项目后我遇到了这个问题。问题来自我这边。在 Eclipse 中,我在 drawable 中放置了一个 png 图像,它实际上是一个 jpg 图像(我只是将扩展名从 .jpg 重命名为 .png)。它在 Eclipse 中运行良好,但在导入 Android Studio 时失败。

任务 ':app:mergeDebugResources' 执行失败。碾碎 Cruncher d.png 失败

我刚刚删除了 d.png 并添加了一个原始 png 文件。有效!

于 2015-04-08T11:19:53.963 回答
1

我在菜单 xml 中删除了一个意外添加的标题:

删除这个:

<?xml version="1.0" encoding="utf-8"?>

留下这个:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
于 2014-03-12T23:36:28.437 回答
1

因此,由于我遇到了类似的问题,所以我想发布我的解决方案: 在此错误之后:

failed to capture snapshot of output files for task…

我清理了我的项目,它又开始工作了。为什么我不知道但它有效。:)

于 2015-02-10T19:37:38.823 回答
1

如果您已经从 Eclipse 导入了项目,那么在 Android Studio 上删除资源 menu/main.xml 并确保您没有任何无效的字符串资源。

由于某种原因,gradle 无法验证 menu/main.xml 文件。

于 2014-02-19T15:39:59.870 回答
0

清单中声明的​​ Activity 发生在我身上,其标题已从字符串文件中删除。

这个错误可以是任何与资源相关的东西。找出错误的最佳方法是:

  1. 保存您的代码。
  2. 返回到最后一次有效的提交。
  3. 添加您的资源会一一更改,直到再次失败。
于 2014-02-13T09:30:47.037 回答
0

我遇到了同样的问题,问题出在我的构建目录上,目前 Android Studio 支持的目录路径少于 100 个字符。

找到了解决方案:

在根build.gradle

allprojects {
    buildDir = "/path/to/build/${rootProject.name}/${project.name}"
}

和文档https://gradle.org/docs/current/userguide/writing_build_scripts.html

于 2018-08-22T09:36:39.903 回答
0

我有一个类似的问题。我想这通常发生在 xml 中有一些不完整的标签或某些东西或某些格式错误的东西时。在我的情况下,主题是问题。在我的xml文件中android studio的设计视图中..我选择了一个新主题......这样它解决了问题......希望这对所有人都有帮助......

于 2016-04-07T06:27:52.010 回答
0

在相应项目的终端中运行此命令。

./gradlew assembleDebug

这将提供有关错误的信息。(逐行验证)

在我的情况下,错误与我包含在我的 gradle 文件中的 JAR 文件有关。最后删除 jar 文件解决了问题。

于 2019-12-07T07:07:28.467 回答