我正在尝试使用最新的工具构建一个Cordova Android项目。我遵循了here的指示
$ cordova create myApp com.myCompany.myApp myApp
$ cd myApp
$ cordova platform add android@6.2.1 --save
$ cordova requirements android --verbose但结果是:
Running command: android list targets
Command finished with error code 0: android list,targets
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-25,android-23
Gradle: not installed
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
Error: CordovaError: Some of requirements check failed
at /usr/local/nodejs_next/lib/node_modules/cordova/src/cli.js:401:45
at _fulfilled (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:749:13)
at /usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:557:44
at flush (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:108:17)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)它似乎无法找到Gradle (不确定它应该在哪里)。
我见过Cordova和Android SDK Tools 25.3的reports问题,但这次似乎不同,我有25.2.3 (见下文)。
我有以下内容(这是在CentOS 6.8上):
$ cordova --version
6.5.0
$ node --version
v6.10.2
$ npm --version
3.10.10
$ java -version
openjdk version "1.8.0_121"
$ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0
$ echo $ANDROID_HOME
/usr/local/android-sdk
# I installed the Android SDK from here
# https://developer.android.com/studio/index.html#downloads
# under "Get just the command line tools"
$ /usr/local/android-sdk/tools/bin/sdkmanager --list
Installed packages:
Path | Version | Description | Location
------- | ------- | ------- | -------
build-tools;23.0.3 | 23.0.3 | Android SDK Build-Tools 23.0.3 | build-tools/23.0.3/
build-tools;25.0.2 | 25.0.2 | Android SDK Build-Tools 25.0.2 | build-tools/25.0.2/
extras;android;m2repository | 47.0.0 | Android Support Repository | extras/android/m2repository/
extras;google;m2repository | 46 | Google Repository | extras/google/m2repository/
patcher;v4 | 1 | SDK Patch Applier v4 | patcher/v4/
platform-tools | 25.0.4 | Android SDK Platform-Tools | platform-tools/
platforms;android-23 | 3 | Android SDK Platform 23 | platforms/android-23/
platforms;android-25 | 3 | Android SDK Platform 25 | platforms/android-25/
tools | 25.2.3 | Android SDK Tools 25.2.3 | tools/ 更新:
在Cordova或Android的文档中似乎没有提到它,但是如果你在没有Android Studio的情况下使用Android命令行工具,你必须手动安装Gradle。一旦你这样做了,它就在你的路径上,这个错误就会消失。
另一件让我困惑的事情是:在旧版本的Android SDK工具中,tools/templates/gradle/wrapper/gradlew中有一个Gradle包装器脚本。这也可以用来安装Gradle,但我发现手动安装会更容易。从最新版本开始,这似乎已被删除。
发布于 2017-11-16 23:01:22
对于Windows:
-Download Gradle的最新版本(https://gradle.org/releases)
gradle文件夹并解压缩文件(我使用C:\Program files (X86)\ -Create )
包含bin目录的路径(C:\Program Files (X86)\gradle\ -Copy )
将路径C:\Program Files (x86)\gradle\bin (在我的示例中) -Set到"Path Environment Variables“
用户变量表和系统变量表的变量名"Path“和变量值"C:\Program Files (x86)\gradle\bin”
您可能需要重新打开“提示命令行”。
要进行测试,请在提示符下键入gradle。
https://stackoverflow.com/questions/43356833
复制相似问题