while building cordova project i get the follwing error on running command cordova build android?
please help with the follwoing code
C:\Users\gaurav-s\hello>cordova build android
ANDROID_HOME=D:\adt-bundle-windows-x86-20140702\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.7.0
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.5.0.
Required by:
:android:unspecified
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradl
e/1.5.0/gradle-1.5.0.pom'. Received status code 407 from server: Proxy Authentic
ation Required
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: 10.001 secs
Error: Error code 1 for command: cmd with args: /s,/c,"C:\Users\gaurav-s\hello\p
latforms\android\gradlew cdvBuildDebug -b C:\Users\gaurav-s\hello\platforms\andr
oid\build.gradle -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"
Build tools have been moved from maven to jcenter. Go to your gradle settings file. Change
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
to
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
It is better to update your gradle to latest version.
This is because of gradle error Download the file
http://services.gradle.org/distributions/gradle-2.14.1-all.zip
and extract it in any of directory and set the path by open cmd and
enter
setx path (extracted direstory)/bin
after reopen cmd and check whether the gradle is works or not by give
gradle -v
it shows the gradle version output .
Now the error is fixed run
ionic build android
Related
When I hit ionic cordova run android the following is happening:
D:\Leraning\myApp>ionic cordova build android
> cordova build android
Android Studio project detected
Running command: "C:\Program Files\nodejs\node.exe" D:\Leraning\myApp\hooks\after_prepare\010_add_platform_class.js D:\Leraning\myApp
ANDROID_HOME=C:\Users\nagasatya.mandalapu\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 busy and 1 incompatible Daemons could not be reused, use --status for details
I have gradle installed and I tried by killing and restarting, but seems the same error.
update
D:\Leraning\myApp\platforms\android>gradle clean
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.0.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Connect to repo.jfrog.org:443 [repo.jfrog.org/34.233.3.28, repo.jfrog.org/52.86.234.14] failed: Read timed out
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 23s
D:\Leraning\myApp\platforms\android>
In the below part of the code from build.gradle
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
Replace
maven {
url 'https://maven.google.com'
}
with
google()
Final part would be
repositories {
jcenter()
google()
}
I have a problem with my Gradle Sync.
I use IntelliJ and Android Studio to build a Flutter / Dart App.
I added 2 new dependencies and now i have an issue with Gradle.
In Android Studio all works fine (The Gradle Sync finishes without failures or warnings), but in IntelliJ it is not working.
* Error running Gradle: Exit code 1 from: C:\Users\stesc\Documents\Programming\timecoder-flutter\android\gradlew.bat app:properties: NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\stesc\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
BUILD FAILED
Total time: 4.669 secs
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\stesc\Documents\Programming\timecoder-flutter\android\build.gradle' line: 25
* What went wrong: A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'. Finished with error: Please review your Gradle project setup in the android/ folder.
> A problem occurred configuring project ':shared_preferences'.
> Could not resolve all dependencies for configuration ':shared_preferences:classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :shared_preferences
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
1. Update your gradle version from project -> android -> build. For me :
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
2. Use latest sdk tool version
3. Open terminal from Tools->Flutter and run these following commands
flutter upgrade
flutter doctor
Make your allpojects->repositories same like buildscript->repositories
If the problem still persists check if your project and shared_preferences both uses the same gradle version. If not, then you may need to make few changes in either your project or in shared_preferences project.
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.0"
}
}
}
}
It fixed for me by adding this to my build.gradle in android folder.
yaa It had solved for me..!
Just go to flutter sdk folder and go to this path \flutter\packages\flutter_tools\gradle\flutter.gradle
and in flutter.gradle file change from this code
buildscript {
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
I had the same problem and solved it too.
Perhaps, will be useful for someone.
This was my problem:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/abc/Desktop/user/project/android/app/build.gradle' line: 14
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.internal.version-check']
> Minimum supported Gradle version is 5.6.4. Current version is 5.4.1. If using the gradle wrapper, try editing the distributionUrl in
/Users/abc/Desktop/user/project/android/gradle/wrapper/gradle-wrapper.properties to gradle-5.6.4-all.zip
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
Command: /Users/abc/Desktop/user/project/android/gradlew app:properties
Please review your Gradle project setup in the android/ folder.
I went to gradle-wrapper.properties and changed this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
The problem was solved.
I have a project that uses com.android.support.test:runner:1.0.1 which I can run and unit test using AndroidStudio but when I try to run the project using the command line I get the following errors:
$ sh gradlew :myproject:clean
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':myproject'.
> Could not resolve all dependencies for configuration ':myproject:_normalDebugAndroidTestApkCopy'.
> Could not find com.android.support:support-annotations:25.0.2.
Searched in the following locations:
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/support-annotations/25.0.2/support-annotations-25.0.2.pom
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/support-annotations/25.0.2/support-annotations-25.0.2.jar
file:/Users/Joan/Development/myproject/git/android-tag/src/myproject/sdk-manager/com/android/support/support-annotations/25.0.2/support-annotations-25.0.2.jar
Required by:
project :myproject
> Could not find com.android.support.test:runner:1.0.1.
Searched in the following locations:
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/test/runner/1.0.1/runner-1.0.1.pom
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/test/runner/1.0.1/runner-1.0.1.jar
file:/Users/Joan/Development/myproject/git/android-tag/src/myproject/sdk-manager/com/android/support/test/runner/1.0.1/runner-1.0.1.jar
Required by:
project :myproject
> Could not find com.android.support.test:rules:1.0.1.
Searched in the following locations:
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/test/rules/1.0.1/rules-1.0.1.pom
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/test/rules/1.0.1/rules-1.0.1.jar
file:/Users/Joan/Development/myproject/git/android-tag/src/myproject/sdk-manager/com/android/support/test/rules/1.0.1/rules-1.0.1.jar
Required by:
project :myproject
* 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.437 secs
I'm using gradle 2.3.3 and for now I can not update to the latest one because of some backward compatibility issues.
how can I fix this issue?
Thanks,
It looks like that you missed the maven { url 'https://maven.google.com' } in your build.gradle. That is why it only searched the maven cache.
Ensure you have something like this in your project's build.gradle:
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
Also, you can run the Gradle task as ./gradlew :myproject:clean instead of sh gradlew :myproject:clean.
I have a Ionic/Cordova project, builds for Android are done with Gradle.
I installed all necessary Android SDKs and the project was building fine for many months, but today it fails with the following error:
Running: d:\git\myproject\platforms\android\gradlew cdvBuildDebug -b d:\git\myproject\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:
BUILD FAILED
Total time: 26.792 secs
:android:unspecified
> Failed to list versions for com.android.tools.build:gradle.
> Unable to load Maven meta-data from https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml.
> Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/maven-metadata.xml'.
> Connection to https://repo1.maven.org refused
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
d:\git\myproject\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "d:\git\myproject\platforms\android\gradlew cdvBuildDebug -b d:\git\myproject\platforms\android\build.gradle -Dorg.gradle.daemon=true"
Error: cmd: Command failed with exit code 1
Cordova command failed with error code 1, aborting!
Clearly, since the project was building just fine for months, everything needed to have it build is already on disk, but the build is probably checking if there are updated version of artifacts in the Maven repo, and this is failing.
This is not a very desired behavior sometimes.
Is it possible to configure the build to always build offline?
So I grepped my repo for com.android.tools.build:gradle and I found it in a few files:
D:\git\myproject\platforms\android\build.gradle\build.gradle
D:\git\myproject\platforms\android\cordova\lib\plugin-build.gradle\plugin-build.gradle
D:\git\myproject\platforms\android\CordovaLib\build.gradle\build.gradle
I changed
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0+'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
Hopefully this solves my issue, although the problem is gone now even with 1.0.0+, so I can't really verify that easily.
You can check which exact version of com.android.tools.build:gradle you have available locally in the following folder when on Windows:
$HOME\.gradle\caches\modules-2\files-2.1\com.android.tools.build\gradle
i have download the android studio 2.2.2,use the gradle 2.14.1 gradle command to compile the project,but failed?
I input gradlew build but failed
the erro log is following
What went wrong:
A problem occurred configuring root project 'MyApplication'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:2.2.2.
Required by:
:MyApplication:unspecified
Could not resolve com.android.tools.build:gradle:2.2.2.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom'.
Server sent an unsupported extension: type_35
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
in build.gradle change this:
repositories {
mavenCentral()
}
to this:
repositories {
mavenCentral()
jcenter()
}