cordova Android 要求失败:“找不到已安装的 Gradle 版本" [英] cordova Android requirements failed: "Could not find an installed version of Gradle"

查看:30
本文介绍了cordova Android 要求失败:“找不到已安装的 Gradle 版本"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用最新的工具构建 Cordova Android 项目.我按照此处的说明进行操作:

$cordova 创建 myApp com.myCompany.myApp myApp$ cd myApp$cordova 平台添加 android@6.2.1 --save$cordova 要求 android --verbose

但结果是:

运行命令:android list targets命令完成,错误代码 0: android list,targetsandroid的需求检查结果:Java JDK:已安装 1.8.0Android SDK:已安装 trueAndroid 目标:已安装 android-25、android-23Gradle:未安装在 Android Studio 中也找不到已安装的 Gradle 版本,或在您的系统上安装 gradle 包装器.请包括gradle在您的路径中,或安装 Android Studio错误:CordovaError:某些需求检查失败在/usr/local/nodejs_next/lib/node_modules/cordova/src/cli.js:401:45在 _fulfilled (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:787:54)在 self.promiseDispatch.done (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:816:30)在 Promise.promise.promiseDispatch (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:749:13)在/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:557:44在刷新 (/usr/local/nodejs_next/lib/node_modules/cordova/node_modules/q/q.js:108:17)在 _combinedTickCallback (internal/process/next_tick.js:73:7)在 process._tickCallback (internal/process/next_tick.js:104:9)

它似乎无法找到 Gradle(不确定它应该在哪里).

我已经看到 报告 Cordova 和 Android SDK 工具 25.3 的问题,但这似乎不同,我有 25.2.3(见下文).

我有以下内容(这是在 CentOS 6.8 上):

$cordova --version6.5.0$节点--版本v6.10.2$ npm --version3.10.10$ java -versionopenjdk 版本1.8.0_121"$回声 $JAVA_HOME/usr/lib/jvm/java-1.8.0$ echo $ANDROID_HOME/usr/local/android-sdk# 我从这里安装了 Android SDK# https://developer.android.com/studio/index.html#downloads# 在仅获取命令行工具"下$/usr/local/android-sdk/tools/bin/sdkmanager --list安装的软件包:路径 |版本 |说明 |地点------- |------- |------- |-------构建工具;23.0.3 |23.0.3 |Android SDK 构建工具 23.0.3 |构建工具/23.0.3/构建工具;25.0.2 |25.0.2 |Android SDK 构建工具 25.0.2 |构建工具/25.0.2/演员;android;m2repository |47.0.0 |Android 支持库 |额外的/安卓/m2repository/演员;谷歌;m2repository |46 |谷歌存储库 |额外的/谷歌/m2repository/修补程序;v4 |1 |SDK 补丁应用程序 v4 |修补程序/v4/平台工具|25.0.4 |Android SDK 平台-工具|平台工具/平台;android-23 |3 |Android SDK 平台 23 |平台/android-23/平台;android-25 |3 |Android SDK 平台 25 |平台/android-25/工具|25.2.3 |Android SDK 工具 25.2.3 |工具/

更新:

Cordova 或 Android 的文档中似乎没有提到它,但是如果您使用的是没有 Android Studio 的 Android 命令行工具,则必须手动安装 Gradle.一旦你这样做了,并且它在你的 PATH 上,这个错误就会消失.

另外一件让我感到困惑的事情:在旧版本的 Android SDK 工具中,tools/templates/gradle/wrapper/gradlew 中有一个 Gradle 包装器脚本.这也可用于安装 Gradle,但我发现手动安装它更容易.从最新版本开始,这似乎已被删除.

解决方案

使用 apt-get 的 linux 解决方案(例如:Ubuntu、Debian)

我有非常相似的问题.我得到错误:

错误:在 Android Studio 中找不到已安装的 Gradle 版本,或在您的系统上安装 gradle 包装器.请包括gradle在您的路径中,或安装 Android Studi

但无一例外.我通过

在 Ubuntu 上解决了它

sudo apt-get install gradle

我还发现了允许在 Ubuntu 中安装最新版本的 gradle 的命令.仅在之前执行第一个命令时才有效(可能某些依赖不正确).

sudo add-apt-repository ppa:cwchien/gradlesudo apt-get 更新sudo apt-get install gradle-ppa

<块引用>

https://wtanaka.com/node/8079

如果它不起作用,请尝试:

export PATH=$PATH:/opt/gradle/gradle-3.5/bin

更多信息:

<块引用>

https://askubuntu.com/questions/915980/package-is-installed-and-is-not-detected-gradle/915993#915993

对于 CentOS

CentOS的gradle安装说明在这个链接下

<块引用>

https://gist.github.com/parzonka/9371885

更新

现在我通过 sdkman 安装 gradle,它类似于 node 的 nvm.

安装sdkman

curl -s "https://get.sdkman.io" |猛击

安装gradle

sdk 安装 gradle 4.0.2

I'm trying to build a Cordova Android project using the most recent tools. I followed the instructions here:

$ cordova create myApp com.myCompany.myApp myApp
$ cd myApp
$ cordova platform add android@6.2.1 --save
$ cordova requirements android --verbose

But the result is:

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)

It doesn't seem to be able to find Gradle (not sure where that's supposed to be).

I've seen reports of issues with Cordova and Android SDK Tools 25.3, but this seems to be different, and I have 25.2.3 (see below).

I have the following (this is on 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/                      

UPDATE:

It doesn't seem to be mentioned anywhere in Cordova's or Android's docs, but if you're using the Android command-line tools without Android Studio, you have to manually install Gradle. Once you do, and it's on your PATH, this error will go away.

An additional thing that was confusing me: in older versions of Android SDK tools, there was a Gradle wrapper script in tools/templates/gradle/wrapper/gradlew. This can also be used to install Gradle, but I found it easier to just install it manually. This seems to have been removed as of the latest version.

解决方案

Solution for linux with apt-get (eg.: Ubuntu, Debian)

I have quite similar problem. I obtained error:

Error: 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 Studi

but without Exception. I solved it on Ubuntu by

sudo apt-get install gradle

I found also commands that allows install newest version of gradle in Ubuntu. It works only when first command is executed before (probably some dependecies are incorrect).

sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle-ppa

https://wtanaka.com/node/8079

If it does not work, try:

export PATH=$PATH:/opt/gradle/gradle-3.5/bin

More info:

https://askubuntu.com/questions/915980/package-is-installed-and-is-not-detected-gradle/915993#915993

For CentOS

Instruction of instalation gradle for CentOS is under this link

https://gist.github.com/parzonka/9371885

Update

Now I installing gradle by sdkman it is something like nvm for node.

Install sdkman

curl -s "https://get.sdkman.io" | bash 

Install gradle

sdk install gradle 4.0.2

这篇关于cordova Android 要求失败:“找不到已安装的 Gradle 版本"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆