这是我得到的确切错误;
F:\XXX\XXX\XXX\myApp-1>cordova build android
ANDROID_HOME=L:\android-sdks
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_45
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configur
ation failure takes precedence.
java.lang.IllegalStateException: buildToolsVersion is not specified.
at com.google.common.base.Preconditions.checkState(Preconditions.java:17
6)
at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.jav
a:599)
at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:566)
at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:563)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.ja
va:55)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.ja
va:47)
at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:562)
at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:559)
at org.gradle.listener.BroadcastDispatch$ActionInvocationHandler.dispatc
h(BroadcastDispatch.java:109)
at org.gradle.listener.BroadcastDispatch$ActionInvocationHandler.dispatc
h(BroadcastDispatch.java:98)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java
:83)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java
:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocat
ionHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy12.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfte
rEvaluate(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(L
ifecycleProjectEvaluator.java:65)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
ect.java:504)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
ect.java:83)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(Task
PathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuil
dConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:129)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:106)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
troller.run(InProcessBuildActionExecuter.java:80)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:36)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:26)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBu
ild.java:47)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(
WatchForDisconnection.java:35)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute
(ResetDeprecationLogger.java:24)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execut
e(StartStopIfBuildAndStop.java:33)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(Forw
ardClientInput.java:71)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(Forw
ardClientInput.java:69)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(For
wardClientInput.java:69)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClien
t.java:60)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBu
ild(EstablishBuildEnvironment.java:70)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:34)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(Da
emonHygieneAction.java:39)
at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:119)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.
run(StartBuildOrRespondWithBusy.java:46)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(Daemon
StateCoordinator.java:246)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecut
orImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
FAILURE: Build failed with an exception.
* Where:
Script 'F:\XXX\XXX\XXX\myApp-1\platforms\android\Cordova
Lib\cordova.gradle' line: 40
* What went wrong:
A problem occurred evaluating root project 'android'.
> cordova_9wgvcsxf5r9stvckgd0tfi8q2$_getAvailableBuildTools_closure3
* 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: 10.712 secs
Error: Error code 1 for command: cmd with args: /s,/c,""F:\XXX\XXX\XXX\myApp-1\platforms\android\gradlew" cdvBuildDebug -b "F:\XXX
\XXX\XXX\myApp-1\platforms\android\build.gradle" -Dorg.gradle.
daemon=true -Pandroid.useDeprecatedNdk=true"
我已经在这里阅读了针对此问题发布的不同解决方案,对我来说只需应用
cordova platforms remove android
然后
cordova platforms add android
用于解决它,但现在甚至没有工作。令人沮丧的是,我在同一台计算机上有两个项目,我一直在一起更新,一个构建而另一个没有。所以我不能责怪ANDROID_HOME等。当我这样说时,我的意思是:
F:\XXX\XXX\XXX\myApp-2>Cordova build android
完美无缺。
有什么想法?我有什么办法毁了我的项目吗?我确定这两种配置都很相似,但如果有人能以正确的方式指出我,我会感激不尽。谢谢。
答案 0 :(得分:1)
我有同样的问题。我把它固定如下: -
打开Android工作室配置。
转到配置> SDK管理器> Android SDK> SDK工具并安装Android SDK Build-Tools。
检查ANDROID_HOME变量。我在Mac上,所以它指向"/Users/<user_name>/Library/Android/sdk/"
。如果您在其他系统上,则需要找到正确的路径。
如果设置不正确,请按如下方式设置: -
export ANDROID_HOME="/Users/<user_name>/Library/Android/sdk/"
现在再次构建它应该可以正常工作
如果不安装了android studio,路径可能会有所不同,您需要找出实际路径。我建议安装Android Studio,因为它会让事情变得更容易。
答案 1 :(得分:1)
我遇到了同样的问题,我的android-versionCode是25.0.3
在config.xml
文件
<widget android-versionCode="25.0.3" id="zakdev.projects.com" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
我将其更改为25
并且它有效
像这样:
<widget android-versionCode="25" id="zakdev.projects.com" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
答案 2 :(得分:0)
我通过用我的项目重新克隆回购来解决了这个问题。如果有帮助的话。
答案 3 :(得分:0)
我通过使用Unix(LF)行结尾保存build.gradle和/或build-extras.gradle解决了这个问题。