android – Cordova Build失败,未指定buildToolsVersion
作者:互联网
这是我得到的确切错误;
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
完美的工作.
有什么想法吗?我有什么办法毁了我的项目吗?我确信这两种配置都很相似,但如果有人能指出我正确的方式,我会感激不尽.谢谢.
解决方法:
我遇到过同样的问题.我把它固定如下: –
打开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 /”
现在再次构建它应该可以正常工作
If you have not installed android studio the path can be different and you need to find out the actual path. I would recommend installing Android Studio as it makes things lot easier.
标签:android,build,cordova,build-tools 来源: https://codeday.me/bug/20190702/1354262.html