Saturday, September 3, 2022

[SOLVED] Gradle error while trying to build android application using Cordova

Issue

I use cordova to build android apps:

$ cordova build android

I got an 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 Studio

Then I tried install gradle:

$ sudo apt install gradle

And then I'm struggling with this one:

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

Solution

I finally could solve the issue. It was something wrong with the gradle. First step: removing it.

$ sudo apt remove gradle

Then i downloaded it manually from the link below

gradle-3.5.zip

Extract then add it's path into the environment using the command below:

$ sudo gedit ~/.bashrc

Add these two path at the bottom of the file:

export GRADLE_HOME=/home/aqil/Android/gradle-3.5
export PATH=$PATH:$GRADLE_HOME/bin

Final step, Tried building but encountered an error:

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.

this is network problem. Proxy helped me to bypass network filtering.



Answered By - Aqilhex
Answer Checked By - Senaida (WPSolving Volunteer)