Jenkins Android Gradle build time download error - android

Linux environment using jenkins android gradle project to build an error
* What went wrong:
A problem occurred configuring project ':app'.
> Could not download glide.jar (com.github.bumptech.glide:glide:3.7.0)
> Could not get resource 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/3.7.0/glide-3.7.0.jar'.
> Could not GET 'https://jcenter.bintray.com/com/github/bumptech/glide/glide/3.7.0/glide-3.7.0.jar'.
> repo.jfrog.org: unknown error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I tried to use the wget way to download the link will prompt an error, then I use the sudo way to download the link successfully. So, how can I make jenkins gradle also use the sudo download, or use other solutions
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
// Exclude the version that the android plugin depends on.
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Please help me, thanks.

You can try upload your local library (in user/.gradle/caches) to Jenkins server, It 's work for me.

I don't think that run the build with super user rights is a good solution, because it's not seems to be possible to resolve dependencies.
Just a suggestion how to solve it: Gradle has it's own local cache for dependencies and doesn't need to download them on every build. So you may use the same Gradle distribution, which is used by Jenkins, and once build your application manually with su rights, to resolve all dependencies and cache them.
Just to note, by default dependencies with dynamic versions are cached for 24 hours only, as it's said in the official docs, but you can change it as:
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 10, 'minutes'
resolutionStrategy.cacheChangingModulesFor 4, 'hours'
}

Related

Could not resolve org.webkit:android-jsc:+

I'm getting an error every time I try to run 'react-native run-android' or './gradlew bundleRelease' for my React Native project.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:collectReleaseDependencies'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
> Could not resolve org.webkit:android-jsc:+.
Required by:
project :app
> Failed to list versions for org.webkit:android-jsc.
> Unable to load Maven meta-data from https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml.
> Could not HEAD 'https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml'.
> 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2m 37s
Here's my build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 24
compileSdkVersion = 30
targetSdkVersion = 30
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "16.0.1"
}
repositories {
google()
mavenCentral()
mavenCentral()
}
dependencies {
classpath 'com.facebook.react:react-native:0.12.+'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
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")
}
maven {
// expo-camera bundles a custom com.google.android:cameraview
url "$rootDir/../node_modules/expo-camera/android/maven"
}
maven { url 'https://maven.google.com' }
maven { url 'https://www.jitpack.io' }
google()
jcenter()
}
}
I can't find any an information about why this is happening bar adding 'www.' to 'https://www.jitpack.io' but it already has that.
'react-native run-android' was working yesterday, since then I changed emulator and also changed java version.
Does anyone know why this is happening?
JCenter is going to shutdown and now is READ-ONLY. And it is getting offline often causing issues with builds and pipelines.
In summary
You will require to update your android/build.gradle file to use mavenCentral() instead of Jcenter().
As per Gradle documentation, JCenter is a mirror of Maven Central, so all of your dependencies should be there.
JCenter is a central artifact repository, like Maven Central. Software
projects use JCenter to distribute their software to other people.
JCenter also serves as a mirror for Maven Central, so any dependencies
available on Maven Central are also available on JCenter (but not vice
versa).
A few things to consider:
In case it is a library (e.g node_modules/react-native-appsflyer), pointing to Jcenter, that is giving you an error... I would advise you to check the library giving you an error has updated a new version with a fix. In case so, update to the new
version to get the changes.
In case the library doesn't have versions with the fix, if you are building in React-native using npm packages, you could potentially take advantage of patch-package library. Because there will a possibility the libraries have not yet released the update removing JCenter from build.gradle.
Applying the patch
You can apply the changes yourself using the Patch Package library. Documentation added in the end for reference.
Go to node_modules/library-with-error/android/build.gradle
Change jcenter() to mavenCentral()
Run: npx patch-package library-with-error
Git add, commit and push
Personal notes:
I did advise the full removal of JCenter instead of adding MavenCentral() to the top because of the shutdown and that JCenter is often getting offline and giving timeout errors.
Based on the current timeline, builds that use JCenter will be able to
resolve dependencies until February 1, 2022 without changes. After
that date, there are no guarantees that you will be able to build
your software if you continue to use JCenter."
Also, Gradle is discouraging the usage of JCenter.
"To discourage new projects from using JCenter, we will be removing
JCenter from our samples and init templates. The new default will be
Maven Central. Gradle itself has no inherent tie to JCenter or Maven
Central, so you can always switch any other repository of your choice.
This change will be effective with the next Gradle release – Gradle
7.0."
In case of dependencies (pom, jar) are not added to Maven, here are instructions on how to add. Add that to the PR with discussions to collaborate.
Useful Links
Add --use-yarn to patch-package command in case your project uses Yarn.
Documentation using Patch package.
We also just ran into this. I believe JCenter is down right now. https://status.bintray.com/

Could not find com.android.support:appcompat-v7:23.1.1

I checked out and built the project at https://github.com/kosiara/artoolkit-android-studio-example
I have Android Studio 4.0.2 on Windows 10.
The build error I get is:
Executing tasks: [:app:assembleDebug] in project D:\Downloads\artoolkit-android-studio-example-master\artoolkit-android-studio-example-master
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':base'.
> Could not resolve all dependencies for configuration ':base:_debugCompile'.
> Could not find com.android.support:appcompat-v7:23.1.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.jar
Required by:
artoolkit-android-studio-example-master:base:unspecified
* 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.346 secs
I'm afraid I don't understand what is wrong.
I'm not sure what needs to be set to version 23.1.1. I looked in my Android SDK manager under SDK Tools, Android SDK Build-Tools and there is no option for 23.1.1. (Is that even where I should be looking?) I see 23.0.1, 23.0.2 (Installed), 23.0.3. Also the Android SDK Platform 23 is installed.
Do I need to add a custom Site to get the missing 23.1.1 option? I have no idea how to do that or what site it would be, if that's what's required.
I suspect there's likely something not set up correctly about my SDK or Android Studio, but I don't know what to check next.
I see this related question but that question has no answer.
I'd like some help getting this example to build.
That version of that module (appcompat-v7) is not in the JCenter repository.
You have to add google maven using the old way when you're using an old version of Gradle, you are not allowed to use google() on Gradle v1.5.
build.gradle (project level)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Android Studio can never download fastutil-7.2.0.jar

Similar question: Android studio gradle stuck at Fastutil.7.2.0.jar
When I'm building my first Android App in Java, Android Studio 4.0 is always complaining:
Could not GET 'https://jcenter.bintray.com/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.jar'. Received status code 400 from server: Bad Request
Enable Gradle 'offline mode' and sync project
However, it's possible to download the jar with the browser.
If I remove jcenter()in build.gradle, a similar error occurs:
Could not HEAD 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.72/kotlin-stdlib-jdk8-1.3.72.pom'. Received status code 400 from server: Bad Request
Enable Gradle 'offline mode' and sync project
This file doesn't even exist.
I tried modifying build.gradle or setting up proxy, but neither works.
gradle.build file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
UPDATE:
Solved. Proxy's fault. Check C:\Users\USERNAME\.gradle\gradle.properties.
Make sure you have installed Command line tools
if not install from
sdk manager > sdk tools > check command line tools and apply

Android Studio 2.2.3 Gradle Build Running Stuck

I download android studio 2.2.3 and load my project. But Gradle Build Running Stuck. It continuously shows that and i am not able to run my app. what is the issue can any one help me with that?
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
If you are behind a proxy, create a gradle.properties file next to your build.gradle file with this :
systemProp.http.proxyHost=YOUR_PROXY
systemProp.http.proxyPort=YOUR_PORT
systemProp.http.proxyUser=USERNAME
systemProp.http.proxyPassword=PASSWORD
systemProp.https.proxyHost=YOUR_PROXY
systemProp.https.proxyPort=YOUR_PORT
systemProp.https.proxyUser=USERNAME
systemProp.https.proxyPassword=PASSWORD
systemProp.http[s].proxyUser and systemProp.http[s].proxyPassword are not required if you don't need to login for your proxy. In such a case, remove these lines.
Make sure you have a internet connection.
If you have it , so maybe android studio couldn't download classes from Jcenter. So you have to force android studio to download classes from other resource like Maven.
To do that open gradle.build file and change the two jcenter() text with mavenCentral() ("C" in maven"C"entral() must be typed in uppercase) and try syncing with gradle again.
You don't need to do that every time you open your project. Just do this every time you create a new project in Android studio.
Solutions:
1. update your Build tools.
2. Reinstall sdk.
In my case, all the executable ".exe" files in "sdk\build-tools\25.0.3" folder were corrupted by virus. solution 2 worked for my perfectly. :)

Build Android APK in Redhat using Gradle in Offline mode

I am using Gradle 2.13 and trying to build android apk in readhat and system does not have internet access.
I am trying to build android apk offline. But it is throwing some exception and not able to figure out what went wrong.
Main build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'PROJECT'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.1.0.
Required by:
:PROJECT:unspecified
> No cached version of com.android.tools.build:gradle:2.1.0 available for offline mode.
> No cached version of com.android.tools.build:gradle:2.1.0 available for offline mode.
* 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: 0.831 secs
Version :
gradle -version
Gradle 2.13
Is there any tutorial available to build an offline apk in redhat/linux machine?
Edit: Update the question.
It happens because the gradle plugin for android 2.13 doesn't exist.
The latest stable version is 2.1.0. Use:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
Don't confuse gradle distribution and the android plugin for gradle.
You can define the gradle distribution used by a project in the file
gradle/wrapper/gradle-wrapper.properties
For example:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

Categories

Resources