cordova中的错误当键入“cordova build android”时

时间:2021-10-04 20:24:37

When i do the cordova build android in cmd, it gives an error:

当我在cmd中使用cordova构建android时,它会出错:

C:\workspace\two>cordova build android
ANDROID_HOME=C:\Program Files\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_77
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.internal.event.BroadcastDispatch$ActionInvocationHandler.d
ispatch(BroadcastDispatch.java:93)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.d
ispatch(BroadcastDispatch.java:82)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(Abstract
BroadcastDispatch.java:44)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatc
h.java:79)
        at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatc
h.java:30)
        at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocat
ionHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy11.afterEvaluate(Unknown Source)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfte
rEvaluate(LifecycleProjectEvaluator.java:67)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(L
ifecycleProjectEvaluator.java:61)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
ect.java:529)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProj
ect.java:90)
        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$2.run(DefaultGradleLa
uncher.java:125)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:52)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:122)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGra
dleLauncher.java:32)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:99)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
eLauncher.java:93)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
tBuildOperationExecutor.java:62)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:93)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:82)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
troller.run(InProcessBuildActionExecuter.java:94)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(Exe
cuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildA
ctionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:43)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:28)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
uousBuildActionExecuter.java:81)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
uousBuildActionExecuter.java:46)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBu
ild.java:52)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(
WatchForDisconnection.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute
(ResetDeprecationLogger.java:26)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.
execute(RequestStopIfSingleUsedDaemon.java:34)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(Forw
ardClientInput.java:74)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(Forw
ardClientInput.java:72)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(For
wardClientInput.java:72)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(
DaemonHealthTracker.java:47)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:120)
        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:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBu
ild(EstablishBuildEnvironment.java:72)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(Hin
tGCAfterBuild.java:41)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(
DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.
run(StartBuildOrRespondWithBusy.java:50)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(Daemon
StateCoordinator.java:246)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.
onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableE
xecutorImpl.java:40)
        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 'C:\workspace\two\platforms\android\CordovaLib\cordova.gradle' line: 64

* What went wrong:
A problem occurred evaluating root project 'android'.
> No installed build tools found. Please install the Android build tools version
 19.1.0 or higher.


BUILD FAILED

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
Total time: 3.089 secs
Error: Error code 1 for command: cmd with args: /s,/c,"C:\workspace\two\platform
s\android\gradlew cdvBuildDebug -b C:\workspace\two\platforms\android\build.grad
le -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"

my SDK is complete and path is correct

我的SDK已完成且路径正确

cordova中的错误当键入“cordova build android”时

Cordova Version 6.1.1 Cordova Platform ls for Android 5.1.1

Cordova版本6.1.1 Cordova平台适用于Android 5.1.1

2 个解决方案

#1


0  

when you go through the CordovaLib library folder (path: platforms->android->CordovaLib) you will find cordova.gradle file.

当您浏览CordovaLib库文件夹(路径:platforms-> android-> CordovaLib)时,您将找到cordova.gradle文件。

when you go through this file you will find this line: doFindLatestInstalledBuildTools('19.1.0')

当你浏览这个文件时,你会发现这一行:doFindLatestInstalledBuildTools('19 .1.0')

this line states that cordova 6.X.X requires build tools version of 19.1.0 or above to be installed on the system.It wasn't recommended to change it.

该行声明cordova 6.X.X需要在系统上安装19.1.0或更高版本的构建工具版本。不建议更改它。

As I see through the pic that you have uploaded, I think better way would be to install 19.1.0 or above, which wasn't present on your system shown in uploaded pic. Then try cordova build android to get the result.

当我看到您上传的图片时,我认为更好的方法是安装19.1.0或更高版本,这在您上传的图片中显示的系统中不存在。然后尝试使用cordova构建android来获得结果。

#2


0  

Hi update your config.xml file

您好更新您的config.xml文件

<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:cdv="http://cordova.apache.org/ns/1.0"
        id="ch.papers.test"
        version="1.0.0"
        android-versionCode="1">

#1


0  

when you go through the CordovaLib library folder (path: platforms->android->CordovaLib) you will find cordova.gradle file.

当您浏览CordovaLib库文件夹(路径:platforms-> android-> CordovaLib)时,您将找到cordova.gradle文件。

when you go through this file you will find this line: doFindLatestInstalledBuildTools('19.1.0')

当你浏览这个文件时,你会发现这一行:doFindLatestInstalledBuildTools('19 .1.0')

this line states that cordova 6.X.X requires build tools version of 19.1.0 or above to be installed on the system.It wasn't recommended to change it.

该行声明cordova 6.X.X需要在系统上安装19.1.0或更高版本的构建工具版本。不建议更改它。

As I see through the pic that you have uploaded, I think better way would be to install 19.1.0 or above, which wasn't present on your system shown in uploaded pic. Then try cordova build android to get the result.

当我看到您上传的图片时,我认为更好的方法是安装19.1.0或更高版本,这在您上传的图片中显示的系统中不存在。然后尝试使用cordova构建android来获得结果。

#2


0  

Hi update your config.xml file

您好更新您的config.xml文件

<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:cdv="http://cordova.apache.org/ns/1.0"
        id="ch.papers.test"
        version="1.0.0"
        android-versionCode="1">