Ionic Cordova android构建失败

时间:2018-03-05 10:08:28

标签: android cordova ionic-framework ionic3

构建项目的android部分时出错。

1>MSBUILD : cordova-build error : Error: cmd: Command failed with exit code 1 Error output:
1>MSBUILD : cordova-build error : FAILURE: Build failed with an exception.
1>MSBUILD : cordova-build error : * What went wrong:
1>MSBUILD : cordova-build error : A problem occurred configuring root project 'android'.
1>MSBUILD : cordova-build error : > Failed to install the following SDK components:
1>MSBUILD : cordova-build error :  [Android SDK Platform 26]
1>MSBUILD : cordova-build error :  The SDK directory (C:\ProgramData\Microsoft\AndroidSDK\25) is not writeable,
1>MSBUILD : cordova-build error :  please update the directory permissions.

我已经安装了 Android SDK Platform 26 ,但位于不同的位置。 (C:\ Program Files(x86)\ Android \ android-sdk)

但是cordova访问了另一个目录(C:\ ProgramData \ Microsoft \ AndroidSDK \ 25)

我在思考,我怎样才能更改Ionic的SDK路径?或者,我如何授予Ionic在特定文件夹上书写的权限?谢谢!

PS:系统信息

Visual Studio 2017 Version 15.5.7
Cordova-Android: 6.2.3
Cordova: 8.0.0
Gradle: 4.6

1 个答案:

答案 0 :(得分:0)

您可以尝试将环境变量ANDROID_HOME设置到终端中的正确目录

    set ANDROID_HOME=C:\<installation location>\
    set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools