" cordova构建android"

时间:2016-12-21 14:16:38

标签: android cordova

当我尝试使用cmd行在Android平台上构建cordova项目时,我总是收到错误:

VM初始化期间发生错误 无法为2097152KB对象堆保留足够的空间。 而这个问题不能通过添加" org.gradle.jvmargs = -Xmx2048m"来解决。在 gradle.properties。

我使用'gradlew compile --stacktrace'获取更多信息,我得到了以下结果:

FAILURE:Build failed with an exception. 
*Where:
Script'E\cordva\helloworld\platforms\android\CordovaLib\cordova.gradle' line:117
*What went wrong:
A problem occurred evaluating root project 'android'。
>Unable to determine Android SDK directory.

图片中的输出。enter image description here

我使用了'gradlew compile --info',得到了以下结果:

    An exception occurred while trying to find the Android build tools.
    Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
    java.lang.IllegalStateException: buildToolsVersion is not specified.
        at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
        at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:645)
        at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:608)
        at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:605)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:156)
        at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:120)
        at com.android.build.gradle.BasePlugin.lambda$createTasks$1(BasePlugin.java:603)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:93)
        at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:82)
    ...

* Where:
Script 'E:\cordova\helloworld\platforms\android\CordovaLib\cordova.gradle' line: 117

* What went wrong:
A problem occurred evaluating root project 'android'.
> Unable to determine Android SDK directory.

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 5.186 secs

enter image description here

我认为关键问题是"无法确定Android SDK目录" 我已经配置了正确的SDK路径,而eclipse可以成功运行android应用程序。也许你可以帮我解决这个问题,或者告诉我一些有用的信息。它让我发疯了。

1 个答案:

答案 0 :(得分:0)

我在Windows(7)这里,这就是我在高级系统设置中所拥有的:

<强>路径

  

%ANDROID_HOME%\工具;%ANDROID_HOME%\平台的工具;

系统变量

  

ANDROID_HOME =&gt; C:\ Program Files \ Android