Search code examples
androidmavenjenkinssupport-v4

Jenkins gradlew build failed to download support-v4


On CentOS, I installed a Jenkins and try to build android on it, I run ./gradlew build in the project folder and it's ok, but when I build with jenkins, it prompt:

Could not resolve all dependencies for configuration ':PagerSlidingTabStripLib:_debugCompile'.
   > Could not resolve com.android.support:support-v4:23.1.0.
     Required by:
         adt-android:PagerSlidingTabStripLib:unspecified
      > Could not resolve com.android.support:support-v4:23.1.0.
         > Could not get resource 'https://jitpack.io/com/android/support/support-v4/23.1.0/support-v4-23.1.0.pom'.
            > Could not GET 'https://jitpack.io/com/android/support/support-v4/23.1.0/support-v4-23.1.0.pom'.
               > Connection to https://jitpack.io refused
      > Could not resolve com.android.support:support-v4:23.1.0.
         > Could not get resource 'https://jcenter.bintray.com/com/android/support/support-v4/23.1.0/support-v4-23.1.0.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/support/support-v4/23.1.0/support-v4-23.1.0.pom'.

The support jars exists under my android sdk folder: android-sdk/extras/android/m2repository/com/android/support/support-v4/ but gradlew can't find it. And the log shows that the maven center does not has the support folder.

I have update the support library and support repositories by : android update sdk --no-ui But it does not works.

This local.properties:

DO NOT check this file into source control.

sdk.dir=/home/jenkins/android-sdk/

============================================

SLOVED


The reason is the jenkins account don't have the read permission for extras/ folder, where the support lib resides. Just chown jenkins extras worked.

The origin permission looks like:

drwxr-x---  5 mysql 4096 12月 22 12:59 extras

Just chown to jenkins and chmod to 775:

drwxrwxr-x  5 jenkins 4096 12月 22 12:59 extras

Solution

  • Setup your environment variable to include Android SDK path

    1. Go to Jenkins > Manage Jenkins > Configure System
    2. Check "Environment variables"
    3. Add name: ANDROID_HOME, value -> your android sdk dir path
    4. Click "add"
    5. Click save

    Also you might also want to check permission of read on the android sdk folder.