当我尝试使用Cordova构建Android时,它显示如下错误,我该如何解决?
Windows 10
Cordova版本:8.0.0
JDK:1.8.0
Gradle版本:4.4
SDK已满(所有Android版本)
F:\Projects\Cordova\board>cordova build android
Android Studio project detected
ANDROID_HOME=E:\SDK
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161\
studio
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
* Where:
Build file 'F:\Projects\Cordova\board\platforms\android\CordovaLib\build.gradle' line: 40
* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> Failed to apply plugin [id 'com.android.library']
> Could not create plugin of type 'LibraryPlugin'.
> com/android/builder/core/ErrorReporter
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
(node:10900) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Build file 'F:\Projects\Cordova\board\platforms\android\CordovaLib\build.gradle' line: 40
* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> Failed to apply plugin [id 'com.android.library']
> Could not create plugin of type 'LibraryPlugin'.
> com/android/builder/core/ErrorReporter
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
(node:10900) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
答案 0 :(得分:0)
转到项目文件夹中的终端,删除并添加android平台。
1. cordova platform rm android
2. cordova platform add android
答案 1 :(得分:0)
谢谢。 通过安装Android Studio并构建项目可以解决此问题。