Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Jenkins to build an android gradle project fails

I'm trying to setup Jenkins on a computer running OSX and I'm running into a problem.

When I'm trying to build the project with my default user account everything works fine, but as soon as im trying to build via Jenkins the build fails with the following output:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':Project'.
> Failed to notify project evaluation listener.
    > A problem occurred configuring project ':libraries:actionbarsherlock'.
        > Failed to notify project evaluation listener.
            > Could not resolve all dependencies for configuration ':libraries:actionbarsherlock:compile'.
                > Could not find com.android.support:support-v4:13.0.0.
                  Required by:
                      workspace.libraries:actionbarsherlock:unspecified

My build.gradle for the project 'libraries:actionbarsherlock' looks like this:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4.2'
    }
}
apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:13.0.0'
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

As far as I know the dependency to com.android.support:support-v4:13.0.0 should be satisfied through the local maven repository installed via the Android SDK Manager. As I said this is working when building on my user account, but it seems to fail when trying to build with Jenkins.

UPDATE

I was able to resolve this issue by checking the user permissions on my android-sdk folder. Problem seemed to be that while the jenkins user had read&write permissions on the android sdk root folder it was lacking the permissions to access stuff installed through the android sdk manager.

like image 998
Daniel H. Avatar asked Jul 09 '13 10:07

Daniel H.


People also ask

Does Jenkins support Gradle?

Gradle provides integration with several development tools and servers, including Eclipse, IntelliJ, Jenkins, and Android Studio.

Why does Gradle Sync Fail?

In some cases when your Gradle files are deleted or corrupted you will not be able to download new Gradle files in android studio. In this case, we have to delete the Gradle files which are present already and then again sync your project to download our Gradle files again.


Video Answer


1 Answers

  • Go to Jenkins > Manage Jenkins > Configure System
  • Check "Environment variables"
  • add name: ANDROID_HOME, value -> your android sdk dir
  • click "add"
  • SCROLL DOWN CLICK SAVE
like image 80
Guy Avatar answered Sep 22 '22 05:09

Guy