Cordova build android exception - android

I'm trying to build an Android application with cordova, when i launch:
cordova build android
an error occurred, and i don't understand how to solve this problem.
If i build my project with Android Studio the gradle is fixed by the IDE, but if i try to compile with cordova command line i have the error that i indicated.
How i can solve ? I need to use command line not Android Studio.
ANDROID_HOME=E:\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_91
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\MY\Desktop\testSpeedTest\platforms\android\build.gradle' line: 22
* What went wrong:
A problem occurred evaluating root project 'android'.
> Failed to apply plugin [id 'android']
> Gradle version 2.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\MY\Desktop\testSpeedTest\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.777 secs
Error: Error code 1 for command: cmd with args: /s,/c,"C:\Users\MY\Desktop\testSpeedTest\platforms\android\gradlew cdvBuildDebug -b C:\Users\MY\Desktop\testSpeedTest\platforms\android\build.gradle -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"

Related

Ionic Android Application not building

C:\Users\Tuladhar\WebstormProjects\myproject>ionic cordova build android
[WARN] Not performing Ionic build for project type: ionic1.
cordova build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\Tuladhar\WebstormProjects\myproject\hooks\after_prepare\010_add_platform_class.js C:\Users\Tuladhar\WebstormProjects\myproject
add to body class: platform-android
ANDROID_HOME=C:\Users\Tuladhar\AppData\Local\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_859uxik73yildsrgrru9xamjo.run(C:\Users\Tuladhar\WebstormProjects\myproject\platforms\android\build.gradle:141)
BUILD FAILED
Total time: 22.164 secs
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 open cp_proj remapped class cache for cxcpcn2de84br0eekalu3p9nv (C:\Users\Tuladhar.gradle\caches\3.3\scripts-remapped\build_c7ur6ql0tv1x27ryhuthd38ad\cxcpcn2de84br0eekalu3p9nv\cp_proj1efd45104ffa2d33563b85b9edda76e3).
Unexpected lock protocol found in lock file. Expected 3, found 0.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: 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 open cp_proj remapped class cache for cxcpcn2de84br0eekalu3p9nv (C:\Users\Tuladhar.gradle\caches\3.3\scripts-remapped\build_c7ur6ql0tv1x27ryhuthd38ad\cxcpcn2de84br0eekalu3p9nv\cp_proj1efd45104ffa2d33563b85b9edda76e3).
Unexpected lock protocol found in lock file. Expected 3, found 0.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[ERROR] An error occurred while running cordova build android (exit code 1).
1.Remove platforms (you can delete it from folder)
2.Remove node_modules (you can delete it from folder)
3.Upgrade your ionic-cli version to the latest (npm update -g ionic )
4.run npm install
5.run ionic cordova platform add android
6.run ionic cordova run android
Try these steps accordingly and it will work. If not try updating android api and sdk tools and re-do the steps.

FAILURE: Build failed with an exception build ionic

I am trying to build a IONIC project but I am facing this exception and I am not able to debug the solution for this.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find Build Tools revision 24.0.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
Error: Error code 1 for command: cmd with args: /s,/c,"C:\application\Qrioh\plat
forms\android\gradlew cdvBuildDebug -b C:\application\Qrioh\platforms\android\bu
ild.gradle -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"
Go to File > Project Structure > Select Module > Properties
Select Build Tools Version same as version selected in Compile Sdk Version.
Hope this will resolve your issue.

Cordova error building after adding plugin

Hello I'm using latest version of Cordova 6.1.0 and Android SDK Tools.
when I add any admob plugins. the following error message returned after using build command.
A problem occurred configuring root project 'android'
how can I fix this?
BTW please don't send workarounds for Android Studio. I just need to be able to build APK files via cordova and I don't use Android Studio.
Full error details as following:
JAVA_HOME=C:\Program Files (x86)\java\jdk1.7.0_71
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':_debugCompile'.
Could not find any version that matches com.google.android.gms:play-services:+.
Searched in the following locations:
https://repo1.maven.org/maven2/com/google/android/gms/play-services/maven-metadata.xml
https://repo1.maven.org/maven2/com/google/android/gms/play-services/
Required by:
:android:unspecified
BUILD FAILED
Total time: 11.78 secs
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Error: Error code 1 for command: cmd with args:
/s,/c,"C:\nm\tests\platforms\android\gradlew cdvBuildDebug -b
C:\nm\tests\platforms\android\build.gradle -Dorg.gradle.daemon=true
-Pandroid.useDeprecatedNdk=true"

Upgrading to Gradle 2.8 breaks my build

I was using Gradle 2.2.1 with Android plugin 1.1.3 and I was a happy man.
However, I decided upgrading to Gradle 2.8 and plugin 1.3.1 and I can't build my project. All I get is an error saying:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> java.lang.NoSuchMethodException: com.android.build.gradle.BasePlugin.getLocalVersion()
> Task with name 'xxxxxxxxx' not found in project ':app'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
This happens whenever I try to build from both Android Studio and command-line.
Any ideas?
PS: My configuration uses the wrapper btw.

Cordova Android Build Failure

I am trying to get the basic Cordova v5.0 Android v4.0 project to build on Mac OS X Yosemite, but keep getting this error. Note: The same process builds fine on Cordova v4. I have uninstalled and reinstalled the Android SDK, Cordova, and even Gradle (but I don't think I need it). I've checked that my Path variable contains the correct paths to /tools and /platform_tools. But when I do the 'cordova build' or 'cordova build android' I always get the same error:
Could not create an instance of type
org.gradle.invocation.DefaultGradle_Decorated.
Further down it says:
You may not have the required environment or OS to build this project
What am I missing?
Here's the full text of what I'm doing:
my_acct$cordova create build_test com.example.build_test "BuildTest"
Creating a new cordova project.
my_acct$cd build_test
my_acct$cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.example.build_test
Name: BuildTest
Activity: MainActivity
Android target: android-22
Copying template files...
Android project created with cordova-android#4.0.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist#1" via npm
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http GET https://registry.npmjs.org/cordova-plugin-whitelist
npm http 304 https://registry.npmjs.org/cordova-plugin-whitelist
Installing "cordova-plugin-whitelist" for android
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
Could not create an instance of type org.gradle.invocation.DefaultGradle_Decorated.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
If I change to use java 1.7 or 1.8, the error changes to:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
Here's the full results for using java 1.7 or 1.8:
my_acct$cordova build
Running command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build
ANDROID_HOME=/Users/my_acct/Documents/Development/android-sdk-macosx/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Running: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew cdvBuildDebug -b /Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle -Dorg.gradle.daemon=true
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.859 secs
/Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/my_acct/Documents/Development/work/build_test/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/my_acct/Documents/Development/work/build_test/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Users/my_acct/Documents/Development/work/build_test/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/Users/my_acct/.node/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
I figured it out. I found old, conflicting .jar files in ~/Library/Java/Extensions. Blew away the entire ~/Library/Java directory. Cordova (and Android Studio) runs great now.
The other way how this problem can be resolved is by changing the repository from
mavenCentral()
to
maven{
url 'https://repo1.maven.org/maven2'
}
in both platforms/android/build.gradle and platforms/android/CordovaLib/build.gradle

Categories

Resources