我正在Android Studio中开发Android应用程序。不太清楚出了什么问题。我几天前成功建造了。任何帮助都会很棒。
这是错误:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
这是我的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
multiDexEnabled true
applicationId "com.tubbs.citychurchob"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.parse.bolts:bolts-android:1+'
compile 'com.android.support:recyclerview-v7:23.1.0'
}
尝试将您的buildToolsVersion
升级到“23.0.1”,如下所示:
compileSdkVersion 23
buildToolsVersion "23.0.1"
如果您没有为此版本安装buildTools,请使用SDKManager作为提示下载它。
在Android Studio中打开:File > Project Structure
并检查JDK位置是否指向您的JDK 1.8目录。
注意:您可以使用compileSdkVersion 24
。它相信我。为此,首先从Oracle下载最新的JDK。
我解决了这个问题。
我试图编译这个项目“Waveform Android” - https://github.com/Semantive/waveform-android
我得到了这个错误。
我在Ubuntu 14.04LTS上使用Android studio。
我安装了JAVA 8。
在我的gradle构建脚本文件中有一些语句如下。
retrolambda {
jdk System.getenv("JAVA8_HOME")
oldJdk System.getenv("JAVA7_HOME")
javaVersion JavaVersion.VERSION_1_7
}
我将“JAVA8_HOME”更改为“JAVA_HOME”,因为在我的环境变量中,java主目录设置为JAVA_HOME而不是JAVA8_HOME,然后它成功构建。
更改构建脚本后。
retrolambda {
jdk System.getenv("JAVA_HOME")
oldJdk System.getenv("JAVA7_HOME")
javaVersion JavaVersion.VERSION_1_7
}
或者另一种方法是你可以创建一个名为JAVA8_HOME的新环境变量,指向正确的JDK位置,但我没有尝试过,因为我不想要每个JDK版本的环境变量。
问题出在命名文件夹中,如果保存项目的文件夹包含特殊字符,则将其删除。如果错误仍然存在,请尝试保存没有空格的文件夹。
我有同样的问题,已经尝试了所有的解决方案但无济于事。
原来,使用Java 9是个问题。安装较低版本Java(jdk 1.8.0_162)对我有用。
请检查您的应用的build.gradle。我遇到了同样的问题,最后我发现问题出在我的build.gradle文件依赖项{}中,它添加了额外的.jar文件,这个文件实际上并不存在于我的项目中作为依赖项。所以我删除了这个依赖项,问题就消失了。
在我第一次运行React Native Android应用程序的路上,我在Mac OS Sierra上遇到了这个问题:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not find tools.jar
我从以下位置更改了Java Development Kit(JDK)的JAVA_HOME环境变量:
export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home'
至 :
export JAVA_HOME='/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home'
在Android Studio中创建项目并在项目设置中查找JDK位置后,我想出了正确版本的位置。
只是补充@yuchaozh answer above,帮助我解决它。 (我没有代表评论)
运行此命令以了解您拥有的Java版本
ls /Library/Java/JavaVirtualMachines/
您将获得如下输出:
jdk1.8.0_111.jdk
替换为Java版本并运行此命令以导出正确的路径。
export JAVA_HOME="/Library/Java/JavaVirtualMachines/<YOUR_JAVA_VERSION>/Contents/Home"
当我尝试在单元测试中使用retrolambda时出现此错误。我没有找到解决方案如何使retrolambda与单元测试一起工作。因此,我使用老式的匿名类而不是lambdas与我的单元测试,它适用于我。
使用这些设置,它将正常工作。
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.pm.motivator"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
}
在构建文件中更改编译文件('AF-Android-SDK.jar')来编译文件('libs / AF-Android-SDK.jar')它会工作
我有同样的问题。我正在与使用Mac的开发团队合作,团队中的其他人都在运行Windows。但是我们使用的是Anroid Studio 2.2-beta和jdk 1.8。如果你在Mac上遇到这个问题,这里有解决方法。不要使用Android Studio 2.2-beta。我花了好几个小时试图调试2.2-beta中的这个错误。我只需更改为Android Studio 2.1.3就解决了这个问题。我们的应用程序在更改Android Studio版本后立即运行。在下载之前,在Android Studio的网站上也会警告mac用户在2.2 beta上运行jdk 1.8。我猜我应该看过精美的哈哈
我遇到了同样的错误。 JAVA_HOME指向正确的JDK版本。所有支持库和构建工具都已更新。仍然面临同样的问题。
我在我的项目中使用Android注释。我添加了一个新的View ..并且在Java文件中已经存在一个具有相同名称的现有视图。当我运行项目时,我没有指出视图已经存在,而是收到了上述错误。
如果其他解决方案不起作用,请检查您的java文件错误。
如果您使用的是Android + Lambdas,则可能会发生这种情况。有时我可以毫无问题地使用Lambdas,但在其他情况下,项目将无法编译并在编译器中提供异常(当我尝试将Lambda或方法引用传递给ScheduledExecutorService.scheduleAtFixedRate时)。
在这个链接(https://bugs.openjdk.java.net/browse/JDK-8169759)中有一个讨论,他们解释了为什么会发生这种情况。与此同时,当编译器允许我时,我只是在我的Android项目中使用lambdas。
您的gradle文件可能已损坏。试试跑步
./gradlew --refresh-dependencies
在android studio里面的终端。
这对我有用
compileSdkVersion 25
buildToolsVersion '25.0.0'
我遇到了类似的问题,但是我不得不在程序文件上手动设置jdk文件夹,所以我向大家特别推荐那些升级到java 8的人,直接指向android studio的项目设置,要么使用嵌入式选项或选择文件夹
更改build.gradle文件中的任何内容将重新同步所有内容,错误将消失。对我来说,我更改了minSdkVersion并且它工作正常。如果系统崩溃或Android Studio未正确关闭,请不要担心会发生这种情况。
在我的情况下,通过更新butterknife没有解决问题
从:“com.jakewharton:butterknife:8.4.0”到:“com.jakewharton:butterknife:8.8.1”
我试过在Adapter类中的@BindView并没有成功。一旦我使用.findViewById(R.id.message_time),编译就已成功完成。
这种问题确实使我们感到焦虑,因为没有提供更多有用的信息。
我不知道我们真的是一样,但我可以提供两种方法来帮助我们解决问题。
1.首先,您可以尝试清理或重新启动Android Studio和您的计算机。在中国,开发人员之间有一句话。
小问题,只需重启。大问题,应重新安装。
以上说法将帮助您多次解决此类问题。
2.其次,我们需要使用一些gradle命令来帮助您找到更多有用的细节。
我遇到了类似的情况如下:
org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:compileDebugJavaWithJavac'.
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:139)
at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:57)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:69)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:30)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:45)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:compileDebugJavaWithJavac'.
at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74)
at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:137)
at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100)
at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75)
at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40)
at org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39)
at org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:57)
at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
at org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:69)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:30)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:45)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
... 3 more
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:50)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:35)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:98)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:51)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:37)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:35)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilationFinalizer.execute(IncrementalCompilationFinalizer.java:39)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilationFinalizer.execute(IncrementalCompilationFinalizer.java:24)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:207)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:133)
at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:125)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 29 more
你知道上面的日志对我们解决这类问题没用。我们需要做一些gradle命令来找到更多有用的信息。
注意:我使用macOS(10.13)和Android Studio(3.1)
转到Android项目目录以执行以下gradle命令:
./gradlew assembleDebug --info
注意:如果在执行上述命令时遇到权限问题,可以使用它来处理它:
chmod +x gradlew
然后我得到了这个(省略了一些不重要的部分):
> Task :app:compileDebugJavaWithJavac FAILED
Putting task artifact state for task ':app:compileDebugJavaWithJavac' into context took 0.0 secs.
file or directory '/Users/ifeegoo/workspace/android/android-bluetooth-color-lamp-karma-lighting/app/src/debug/java', not found
Up-to-date check for task ':app:compileDebugJavaWithJavac' took 0.009 secs. It is not up-to-date because:
Task has failed previously.
All input files are considered out-of-date for incremental task ':app:compileDebugJavaWithJavac'.
Compiling with source level 1.7 and target level 1.7.
Creating new cache for classAnalysis, path /Users/ifeegoo/workspace/android/android-bluetooth-color-lamp-karma-lighting/.gradle/4.4.1/javaCompile/classAnalysis.bin, access org.gradle.cache.internal.DefaultCacheAccess@156d7504
Creating new cache for jarAnalysis, path /Users/ifeegoo/workspace/android/android-bluetooth-color-lamp-karma-lighting/.gradle/4.4.1/javaCompile/jarAnalysis.bin, access org.gradle.cache.internal.DefaultCacheAccess@156d7504
Creating new cache for taskJars, path /Users/ifeegoo/workspace/android/android-bluetooth-color-lamp-karma-lighting/.gradle/4.4.1/javaCompile/taskJars.bin, access org.gradle.cache.internal.DefaultCacheAccess@156d7504
Creating new cache for taskHistory, path /Users/ifeegoo/workspace/android/android-bluetooth-color-lamp-karma-lighting/.gradle/4.4.1/javaCompile/taskHistory.bin, access org.gradle.cache.internal.DefaultCacheAccess@156d7504
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
file or directory '/Users/ifeegoo/workspace/android/android-bluetooth-color-lamp-karma-lighting/app/src/debug/java', not found
Compiling with JDK Java compiler API.
/Users/ifeegoo/workspace/android/android-bluetooth-color-lamp-karma-lighting/app/src/main/java/com/chipsguide/app/colorbluetoothlamp/v2/karmalighting/frags/banner/VideoActivity.java:10: error: package com.android.tedcoder.wkvideoplayer.model does not exist
import com.android.tedcoder.wkvideoplayer.model.Video;
^
/Users/ifeegoo/workspace/android/android-bluetooth-color-lamp-karma-lighting/app/src/main/java/com/chipsguide/app/colorbluetoothlamp/v2/karmalighting/frags/banner/VideoActivity.java:11: error: package com.android.tedcoder.wkvideoplayer.model does not exist
import com.android.tedcoder.wkvideoplayer.model.VideoUrl;
^
/Users/ifeegoo/workspace/android/android-bluetooth-color-lamp-karma-lighting/app/src/main/java/com/chipsguide/app/colorbluetoothlamp/v2/karmalighting/frags/banner/VideoActivity.java:12: error: package com.android.tedcoder.wkvideoplayer.view does not exist
import com.android.tedcoder.wkvideoplayer.view.MediaController;
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
35 errors
:app:compileDebugJavaWithJavac (Thread[Task worker for ':',5,main]) completed. Took 0.84 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --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 2s
15 actionable tasks: 1 executed, 14 up-to-date
我有最重要的细节信息,因为一个模块导入不正确,这使得课程没有找到。所以,我得到了它并解决了问题。
其他一些gradle命令:
*clean project
./gradlew clean
*build project
./gradlew build
*build for debug package
./gradlew assembleDebug or ./gradlew aD
*build for release package
./gradlew assembleRelease or ./gradlew aR
*build for release package and install
./gradlew installRelease or ./gradlew iR Release
*build for debug package and install
./gradlew installDebug or ./gradlew iD Debug
*uninstall release package
./gradlew uninstallRelease or ./gradlew uR
*uninstall debug package
./gradlew uninstallDebug or ./gradlew uD
*all the above command + "--info" or "--debug" or "--scan" or "--stacktrace" can get more detail information.
如果您无法通过--info获取足够的信息,请使用--debug / - scan / - stacktrace。
请记住,更多细节将帮助您解决问题。
注意:Gradle命令非常强大,如果你想做更复杂的操作,特别是关于如何处理调试/发布或多通道或模块,去Android Studio检查Gradle Window,那么你就会知道怎么做它!
这是因为你没有设置$ JAVA_HOME。如果您使用的是Mac:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home"
in .bash_profile
第一步:
第二步:
我尝试了两种,但没有任何效果。我这里的事情是解决方案。
从你的项目 -
转到Gradle Scripts >> build.gradle(Module:app)然后删除下面的代码(如果存在)
.............................................
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_6
}
.............................................
删除它然后清理项目然后运行。没有java home需要设置,无需更改版本
我想使用Realm for Android,这需要Retrolambda。问题是Retrolambda与杰克的冲突。
所以我从下面原始答案中显示的gradle中删除了我的Jack选项配置,并进行了以下更改:
// ---------------------------------------------
// Project build.gradle file
// ---------------------------------------------
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
classpath "io.realm:realm-gradle-plugin:3.1.4"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
和
// ---------------------------------------------
// Module build.gradle file
// ---------------------------------------------
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
...
如果您进行了上述更改,则仍会出现以下错误:
Execution failed for task ':app:compileDebugJavaWithJavac'.
com.sun.tools.javac.util.Context.put(Ljava/lang/Class;Ljava/lang/Object;)V
尝试删除以下文件:
/Library/Java/Extensions/tools.jar
然后:
所有的修改都为我修好了。
注意:
我不确定tools.jar是做什么的,或者它是否重要。与此Stackoverflow问题中的其他用法一样:
Can't build Java project on OSX yosemite
我们很遗憾不得不使用AUSKey(澳大利亚政府使用一些古老的恐龙Java认证密钥系统来验证我们的计算机,然后才能登录澳大利亚商业门户网站)。
我猜测tools.jar
可能是AUSKey的JAR文件。
如果您担心,您可以备份整个文件夹而不是删除此文件,并将其保存在某个地方以防万一您无法再次登录澳大利亚商业门户网站。
希望有所帮助:D
我今天遇到了这个问题(2016年6月27日)。
我下载了Android Studio 2.2并将JDK更新为1.8。
除了指向正确的JDK路径的上述答案之外,我还必须在build.gradle(Module: app)
文件中另外指定JDK版本:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
生成的文件如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.mycompany.appname"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
}
另请注意,如果您遇到有关Java 8 language features requires Jack enabled
的错误,则需要将以下内容添加到您的gradle文件中(如上所示):
jackOptions {
enabled true
}
在这之后,我终于在我的手机上运行了我的新项目应用程序。
如果以上所有内容都不起作用,请尝试从.gradle
全局文件夹中删除缓存
rm -rf ~/.gradle/caches
react-native run-android
rm -rf ~/.gradle
react-native run-android