Error running gradle command but not using AndroidStudio - android

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.

Related

Problem gradle react-native for run android

I have ejected Expo from my project to run it on react-native. the problem is run-android doesn't work and it has gradle problem.
here is my terminal result :
> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 863 file(s) to forward-jetify. Using 12 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'lasttry'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find gradle-4.2.2.jar (com.android.tools.build:gradle:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.2.2/gradle-4.2.2.jar
> Could not find builder-4.2.2.jar (com.android.tools.build:builder:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/4.2.2/builder-4.2.2.jar
> Could not find bundletool-1.1.0.jar (com.android.tools.build:bundletool:1.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.1.0/bundletool-1.1.0.jar
> Could not find aapt2-proto-4.2.2-7147631.jar (com.android.tools.build:aapt2-proto:4.2.2-7147631).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-proto/4.2.2-7147631/aapt2-proto-4.2.2-7147631.jar
> Could not find databinding-compiler-common-4.2.2.jar (androidx.databinding:databinding-compiler-common:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler-common/4.2.2/databinding-compiler-common-4.2.2.jar
> Could not find sdklib-27.2.2.jar (com.android.tools:sdklib:27.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/sdklib/27.2.2/sdklib-27.2.2.jar
> Could not find protos-27.2.2.jar (com.android.tools.analytics-library:protos:27.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/27.2.2/protos-27.2.2.jar
* 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 2s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'lasttry'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find gradle-4.2.2.jar (com.android.tools.build:gradle:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.2.2/gradle-4.2.2.jar
> Could not find builder-4.2.2.jar (com.android.tools.build:builder:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/4.2.2/builder-4.2.2.jar
> Could not find bundletool-1.1.0.jar (com.android.tools.build:bundletool:1.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.1.0/bundletool-1.1.0.jar
> Could not find aapt2-proto-4.2.2-7147631.jar (com.android.tools.build:aapt2-proto:4.2.2-7147631).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-proto/4.2.2-7147631/aapt2-proto-4.2.2-7147631.jar
> Could not find databinding-compiler-common-4.2.2.jar (androidx.databinding:databinding-compiler-common:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler-common/4.2.2/databinding-compiler-common-4.2.2.jar
> Could not find sdklib-27.2.2.jar (com.android.tools:sdklib:27.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/sdklib/27.2.2/sdklib-27.2.2.jar
> Could not find protos-27.2.2.jar (com.android.tools.analytics-library:protos:27.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/27.2.2/protos-27.2.2.jar
* 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 2s
at makeError (D:\project\last\lasttry\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at D:\project\last\lasttry\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (D:\project\last\lasttry\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (D:\project\last\lasttry\node_modules\#react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
before this i was building app on my own device connected to PC. so i never tried simulator.
here is more data which might u need to see :
gradle-wrapper.properties :
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
and here is what i have tried : ./gradlew clean , running on different port, installing new project

when i implement third party library in android studio ,android studio show error in Task Failed with an exception in build

1: Task failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.irozon.sneaker:sneaker:2.0.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/irozon/sneaker/sneaker/2.0.0/sneaker-2.0.0.pom
- https://repo.maven.apache.org/maven2/com/irozon/sneaker/sneaker/2.0.0/sneaker-2.0.0.pom
Required by:
project :app
Could not find com.kaopiz:kprogresshud:1.2.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/kaopiz/kprogresshud/1.2.0/kprogresshud-1.2.0.pom
- https://repo.maven.apache.org/maven2/com/kaopiz/kprogresshud/1.2.0/kprogresshud-1.2.0.pom
Required by:
project :app
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.
==============================================================================
It's not blame of Android Studio, it's just Gradle can't find your declared dependency in your maven repositories.
That library stores in jitpack repository you not declared, just declare it in repositories block in your build.gradle in app module.
maven { url 'https://jitpack.io' }
or if you use Gradle kotlin DSL
maven(url = "https://jitpack.io")

Cordova build error on android

I'm trying to build and execute my cordova project, but i'm facing the error:
BUILD FAILED
Total time: 5.696 secs FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not find common.jar (android.arch.core:common:1.1.0). Searched in the following locations:
https://jcenter.bintray.com/android/arch/core/common/1.1.0/common-1.1.0.jar
* 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 find common.jar (android.arch.core:common:1.1.0).
Searched in the following locations:
https://jcenter.bintray.com/android/arch/core/common/1.1.0/common-1.1.0.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
The point is that the same project was able to build/run last week, and today dont work anymore.
Anyone had this problem and found some solution?
Open platforms/android/ then build.gradle
Add maven { url 'https://maven.google.com' } before jcenter()
allprojects
{
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
}
}
google() and maven { url 'https://maven.google.com' } are pointing to the same repo, google() is a Google's Maven repo shortcut. You can add google() instead of maven { url 'https://maven.google.com' } IF you are using :
Gradle >= v.4.x+
It seems the order matters,
this works for me

ionic cordova run android is giving gradle error

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 download the android studio 2.2.2,use the gradle 2.14.1 gradle command to compile the project,but failed?

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()
}

Categories

Resources