简体   繁体   中英

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.

  • 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

I was able to solve this issue just now for myself.

Steps:

  1. Create a file in the root directory of your project called "local.properties"
  2. Put only the following in the file: sdk.dir=/home/patience/android-studio/sdk

Then Rebuild and it should work. This was on Fedora Linux for reference.

它看起来像你的jenkins盒子上的Android SDK没有安装“Android Support Repository”组件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM