当前位置: 首页 > 知识库问答 >
问题:

ionic build android失败--找不到构建工具

姬博瀚
2023-03-14

我有一个Ionic/Cordova项目,我想通过模拟器模拟这个项目,所以我使用“Ionic platform add android”命令添加了android平台,然后我试图运行“Ionic build android”命令,但失败了,输出是:

ionic build android

Running command: "C:\Program Files\nodejs\node.exe" "D:\web development\My-Stuff                                                                                                                s\ionic\Learn ionic by building apps\mynote\hooks\after_prepare\010_add_platform                                                                                                                _class.js" "D:/web development/My-Stuffs/ionic/Learn ionic by building apps/myno                                                                                                                te"
add to body class: platform-android
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_80
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.$Proxy13.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:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor                                                                                                                .java:615)
        at java.lang.Thread.run(Thread.java:745)

FAILURE: Build failed with an exception.

* Where:
Script 'D:\web development\My-Stuffs\ionic\Learn ionic by building apps\mynote\p                                                                                                                latforms\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.

* 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: 1 mins 16.86 secs
ERROR building one of the platforms: Error code 1 for command: cmd with args: /s                                                                                                                ,/c,""D:\web development\My-Stuffs\ionic\Learn ionic by building apps\mynote\pla                                                                                                                tforms\android\gradlew" cdvBuildDebug -b "D:\web development\My-Stuffs\ionic\Lea                                                                                                                rn ionic by building apps\mynote\platforms\android\build.gradle" -Dorg.gradle.da                                                                                                                emon=true -Pandroid.useDeprecatedNdk=true"
You may not have the required environment or OS to build this project
Error: Error code 1 for command: cmd with args: /s,/c,""D:\web development\My-St                                                                                                                uffs\ionic\Learn ionic by building apps\mynote\platforms\android\gradlew" cdvBui                                                                                                                ldDebug -b "D:\web development\My-Stuffs\ionic\Learn ionic by building apps\myno                                                                                                                te\platforms\android\build.gradle" -Dorg.gradle.daemon=true -Pandroid.useDepreca                                                                                                                tedNdk=true"

我的系统信息:

Cordova CLI: 6.0.0
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
OS: Windows 7 SP1
Node Version: v4.4.0

共有1个答案

羊舌富
2023-03-14

我正面临这个问题。问题是我的ANDROID_HOME路径指向Android Studio的文件夹。我把它改成指向我的Android SDK文件夹,问题就解决了。

检查您的Android_Home:echo$Android_Home

它应该指向Android SDK文件夹:export android_home=“your-android-sdk-folder”

 类似资料: