10

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.

1
  • Your update is what was wrong with my build also, thanks Commented Jul 30, 2014 at 15:18

3 Answers 3

52
  • 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
Sign up to request clarification or add additional context in comments.

2 Comments

Works, even though this error started happening randomly on my system - without any rhyme or reason...
I would prefer this solution over modifying local.properties. local.properties is created and used in the IDE. The dev machine will surely have different paths. Possible maintenance issue.
4

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.

3 Comments

While this was not the problem in my case, it might be one of the more common problems when trying to build a gradle android project with jenkins.
After adding in the right location this worked for me. I am building from the terminal and testing the app so I don't have android studio hooked up to the sdk. I got mine via homebrew
local.properties shouldn't really be used for CI builds. i.e., it should not be checked in.
1

It just looks like the Android SDK on your jenkins box does not have the "Android Support Repository" component installed.

5 Comments

Since I‘m running Jenkins on my development box right now, I think I can safely say that the Android Support Repository is installed. My best guess right now is that the jenkins user account can't find or can't access the android sdk, even though I have set $ANDROID_HOME and local.properties with a path to the sdk.
I have had the exact same issue, and I've seen at least one other posting besides this with the same issue. I'm running Fedora Linux, and the other posting I saw was running Linux as well, Ubuntu mind you. Is this a common thread? Regardless, @Xav can we possibly get a link to the Maven repo so we can just add it manually? This is a blocking issue for me. Thanks.
The repo is inside the SDK under extras/android/m2repository/
OK, figured it out, turns out the fix was to create a local.properties file and specify "sdk.dir=/path/to/sdk/".
I have the same problem and creating the local.properties did the trick, I think is a bug in Gradle Wrapper because this file should never be in your GIT or SVN repo but... when you import into Android Studio it complains about this missing file and create it for you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.