简体   繁体   中英

Jenkins compiling android results in The system cannot find the file specified

I am trying to build an android project with Jenkins. Everything works when I do it from the Android Studio but when I try to execute this pipeline:

pipeline {
  agent any
  options {
    // Stop the build early in case of compile or test failures
    skipStagesAfterUnstable()
  }
  stages {
    stage('Build') {
        steps {
            git url: 'git project', branch: 'dev',
             credentialsId: 'my id'
        }
    }
    stage('Compile') {
      steps {
        sh './gradlew app:compileDevelopmentDebugSources'
      }
    }
  }
}

Almost everything is compiling but then at the end it results in:

* What went wrong:

Execution failed for task ':app:processDevelopmentDebugResources'.

Could not resolve all files for configuration ':app:developmentDebugRuntimeClasspath'. Failed to transform appcompat-1.3.1.aar (androidx.appcompat:appcompat:1.3.1) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for AarResourcesCompilerTransform: C:\Windows\System32\config\systemprofile.gradle\caches\transforms-3\9e32ce413d257d430ee86cf55f3ee638\transformed\appcompat-1.3.1. > Android resource compilation failed ERROR:AAPT: C:\Windows\System32\config\systemprofile.gradle\caches\transforms-3\6f89bc5bb3a2c965d5a4f83c7a248dca\transformed\androidx.appcompat: error: The system cannot find the file specified. (2).

Failed to transform core-1.8.0-rc01.aar (androidx.core:core:1.8.0-rc01) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for AarResourcesCompilerTransform: C:\Windows\System32\config\systemprofile.gradle\caches\transforms-3\88b483c698053fa2a8111125a6a5e48d\transformed\core-1.8.0-rc01. > Android resource compilation failed ERROR:AAPT: C:\Windows\System32\config\systemprofile.gradle\caches\transforms-3\ed6fb526d8841f8ccb993b181101e77a\transformed\androidx.core: error: The system cannot find the file specified. (2).

Failed to transform core-1.8.0-rc01.aar (androidx.core:core:1.8.0-rc01) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}. > Execution failed for AarResourcesCompilerTransform: C:\Windows\System32\config\systemprofile.gradle\caches\transforms-3\88b483c698053fa2a8111125a6a5e48d\transformed\core-1.8.0-rc01. > Android resource compilation failed ERROR:AAPT: C:\Windows\System32\config\systemprofile.gradle\caches\transforms-3\ed6fb526d8841f8ccb993b181101e77a\transformed\androidx.core: error: The system cannot find the file specified. (2).

Failed to transform core-1.8.0-rc01.aar (androidx.core:core:1.8.0-rc01) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.status=release}. > Execution failed for AarResourcesCompilerTransform: C:\Windows\System32\config\systemprofile.gradle\caches\transforms-3\88b483c698053fa2a8111125a6a5e48d\transformed\core-1.8.0-rc01. > Android resource compilation failed ERROR:AAPT: C:\Windows\System32\config\systemprofile.gradle\caches\transforms-3\ed6fb526d8841f8ccb993b181101e77a\transformed\androidx.core: error: The system cannot find the file specified. (2).

I honestly have no idea what the issue might be because as I said it's building/running from the Android Studio.

It turns out this issue can be fixed by adding GRADLE_USER_HOME inside Jenkins.

Here are useful links:

I saw the answer from here: https://serverfault.com/questions/1026538/jenkins-integration-with-android-studio

Similar issue: Jenkins - Execution failed for task ':app:mergeDebugResources'

I tried this solution.

Locate Gradle manually.

navigate to configure jenkins and add a variable with the name of GRADLE_USER_HOME and value of C:\Users<username>.gradle (Windows)

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