AndroidStudio运行java的main方法

新建一个java文件,含有main方法

package com.why.project.androidcnblogsdemo.utils;

/**
 * Created by HaiyuKing
 * Used
 */

public class RunMain {

    public static void main(String[] args) {
        String result = "Run Main";
        System.out.println(result);
    }
}

点击选中类文件——鼠标右键——Run 'xxx.main()'

Android Studio进行编译

有时候可能会报错

Error:Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

如何查看更多日志信息

在File->setting->Build,Execution,Deployment->Compiler 的Options配置(--debug --stacktrace),打印日志信息。

Error:Gradle: 11:23:31.485 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
11:23:31.485 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
11:23:31.485 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
11:23:31.485 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
11:23:31.485 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:processDebugResources'.
11:23:31.486 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Failed to process resources, see aapt output above for details.
11:23:31.486 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
11:23:31.486 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
11:23:31.486 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]  Run with --scan to get full insights.
11:23:31.486 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
11:23:31.486 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
11:23:31.487 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'.
11:23:31.487 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
11:23:31.487 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
11:23:31.487 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
11:23:31.487 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
11:23:31.487 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
11:23:31.487 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
11:23:31.487 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
11:23:31.488 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
11:23:31.488 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
11:23:31.488 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
11:23:31.488 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
11:23:31.488 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
11:23:31.488 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
11:23:31.488 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
11:23:31.488 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
11:23:31.488 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
11:23:31.489 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
11:23:31.489 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
11:23:31.489 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
11:23:31.489 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
11:23:31.489 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
11:23:31.490 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
11:23:31.490 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
11:23:31.490 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
11:23:31.490 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
11:23:31.492 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
11:23:31.492 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
11:23:31.492 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
11:23:31.492 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.tooling.BuildException: Failed to process resources, see aapt output above for details.
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:512)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.doFullTaskAction(LinkApplicationAndroidResourcesTask.java:249)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
11:23:31.493 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     ... 29 more
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     Suppressed: java.lang.RuntimeException: Some file processing failed, see logs for details
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at com.android.builder.internal.aapt.QueuedResourceProcessor.waitForAll(QueuedResourceProcessor.java:121)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at com.android.builder.internal.aapt.QueuedResourceProcessor.end(QueuedResourceProcessor.java:141)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at com.android.builder.internal.aapt.v2.QueueableAapt2.close(QueueableAapt2.java:104)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.doFullTaskAction(LinkApplicationAndroidResourcesTask.java:293)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at sun.reflect.GeneratedMethodAccessor120.invoke(Unknown Source)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at java.lang.reflect.Method.invoke(Method.java:498)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
11:23:31.494 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
11:23:31.495 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
11:23:31.496 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]         at java.lang.Thread.run(Thread.java:745)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: com.android.ide.common.process.ProcessException: Failed to execute aapt
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:809)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:797)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:491)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     ... 42 more
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
11:23:31.497 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.builder.internal.aapt.AbstractAapt.link(AbstractAapt.java:34)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:807)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     ... 44 more
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$makeValidatedPackage$1(QueueableAapt2.java:166)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:443)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:395)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:312)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]     at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
11:23:31.498 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 7s
更多日志信息

解决方案:

在项目根目录下的gradle.properties文件(如果没有,新建)中添加以下配置:

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.enableAapt2=false

原因:

AndroidStudio升级后,打开旧项目没问题,但是新建项目编译会报错:Errorcom.android.tools.aapt2.Aapt2Exception AAPT2 error check logs for details。在Google gradle插件升级到3.0之后(Google Gradle插件在项目根目录下的build.gradle中引入,参考下图),就默认启用了appt2,这么做是为了加快编译的速度。但是如果你的Gradle缓存目录不存在或者(一般在用户目录下,C:\Users\用户名\.gradle)中含有中文名称,那么就悲剧了,会出现上面的问题。个人总结原因是:Android Gradle 3.0之后对gradle缓存目录中的中文目录支持存在问题,所以导致了这样的错误。

运行日志

参考资料

AndroidStudio运行java的main方法

Execution failed for task ':app:processDebugResources'

Running “cordova build android” - unable to find attribute android:fontVariationSettings and android:ttcIndex

AndroidStudio升级后编译项目出现Aapt2Exception异常的问题解决方案

posted @ 2018-08-19 08:02  HaiyuKing  阅读(14525)  评论(0编辑  收藏  举报