Gradle 尝试使用 Cordova 构建应用程序时出错
Gradle error while try to build app using Cordova
我正在使用 Ubuntu,我在我的系统上成功安装了 Cordova,现在我正在尝试使用此命令构建应用程序:
$ cordova build android
当前错误之前,我遇到过:
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 Studio
然后我尝试了:
$ sudo apt install gradle
已安装成功
然后我正在努力解决这个问题:
aqil@dell:~/hello$ cordova build
ANDROID_HOME=/home/aqil/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
/usr/lib/jvm/java-8-openjdk-amd64/bin/java: symbol lookup error: /usr/lib/jni/libnative-platform-curses.so: undefined symbol: tgetent
Error: /usr/share/gradle/bin/gradle: Command failed with exit code 127
我终于找到了问题所在,我的 gradle 出了点问题,我先删除了它:
$ sudo apt remove gradle
因为我是从终端下载的,后来我从下面的link手动下载了
将它解压到某个地方,并使用以下代码将其路径包含在我的环境中:
$ sudo gedit ~/.bashrc
在本页底部,我通过以下代码定义了 gradle 的路径:
export GRADLE_HOME=/home/aqil/Android/gradle-3.5
export PATH=$PATH:$GRADLE_HOME/bin
然后我尝试构建,但遇到错误:
BUILD FAILED
Total time: 9 mins 33.837 secs Error: /home/aqil/App/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'android'. Could not resolve all dependencies for configuration ':_debugApk'. A problem occurred configuring project ':CordovaLib'. Could not resolve all dependencies for configuration ':CordovaLib:classpath'. Could not resolve com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3. Required by: project :CordovaLib Could not resolve com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3. Could not get resource 'https://jcenter.bintray.com/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7.3/gradle-bintray-plugin-1.7.3.pom'. Could not GET 'https://jcenter.bintray.com/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7.3/gradle-bintray-plugin-1.7.3.pom'. Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out (Connection timed out)
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
我相信它的连接问题,所以我使用了 Tor 代理,然后它对我有用,尝试使用 Tor 代理和 none,它应该也适合你。
这对我有用:
- 移除 Gradle
sudo apt-get remove gradle
- 将此添加到您的 .bashrc 文件中:
export PATH=${PATH}:/opt/android-studio/gradle/gradle-X.XX.X/bin
(其中 X.XX.X
是此路径下的版本。)
现在 cordova build android
应该可以正常工作了。
我正在使用 Ubuntu,我在我的系统上成功安装了 Cordova,现在我正在尝试使用此命令构建应用程序:
$ cordova build android
当前错误之前,我遇到过:
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 Studio
然后我尝试了:
$ sudo apt install gradle
已安装成功
然后我正在努力解决这个问题:
aqil@dell:~/hello$ cordova build
ANDROID_HOME=/home/aqil/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
/usr/lib/jvm/java-8-openjdk-amd64/bin/java: symbol lookup error: /usr/lib/jni/libnative-platform-curses.so: undefined symbol: tgetent
Error: /usr/share/gradle/bin/gradle: Command failed with exit code 127
我终于找到了问题所在,我的 gradle 出了点问题,我先删除了它:
$ sudo apt remove gradle
因为我是从终端下载的,后来我从下面的link手动下载了
将它解压到某个地方,并使用以下代码将其路径包含在我的环境中:
$ sudo gedit ~/.bashrc
在本页底部,我通过以下代码定义了 gradle 的路径:
export GRADLE_HOME=/home/aqil/Android/gradle-3.5
export PATH=$PATH:$GRADLE_HOME/bin
然后我尝试构建,但遇到错误:
BUILD FAILED
Total time: 9 mins 33.837 secs Error: /home/aqil/App/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'android'. Could not resolve all dependencies for configuration ':_debugApk'. A problem occurred configuring project ':CordovaLib'. Could not resolve all dependencies for configuration ':CordovaLib:classpath'. Could not resolve com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3. Required by: project :CordovaLib Could not resolve com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3. Could not get resource 'https://jcenter.bintray.com/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7.3/gradle-bintray-plugin-1.7.3.pom'. Could not GET 'https://jcenter.bintray.com/com/jfrog/bintray/gradle/gradle-bintray-plugin/1.7.3/gradle-bintray-plugin-1.7.3.pom'. Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out (Connection timed out) Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
我相信它的连接问题,所以我使用了 Tor 代理,然后它对我有用,尝试使用 Tor 代理和 none,它应该也适合你。
这对我有用:
- 移除 Gradle
sudo apt-get remove gradle
- 将此添加到您的 .bashrc 文件中:
export PATH=${PATH}:/opt/android-studio/gradle/gradle-X.XX.X/bin
(其中X.XX.X
是此路径下的版本。)
现在 cordova build android
应该可以正常工作了。