我试图使用jenkins ci/cd为我的应用程序运行所有的ui测试,但我经常遇到错误,这是由app:processDebugResources命令失败造成的。当我在Android构建项目时,它不会抛出任何错误并正确构建。
在jenkins中执行connectedAndroidTest gradle命令之后:
Task :app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform appcompat-1.3.0.aar (androidx.appcompat:appcompat:1.3.0) 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\9398b1795b0a45e239a8370198c80687\transformed\appcompat-1.3.0.
> Android resource compilation failed
ERROR:AAPT: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\5b50c60af17e66ade7be3083cf0fe04d\transformed\androidx.appcompat: error: Не удается найти указанный файл. (2).
> Failed to transform appcompat-1.3.0.aar (androidx.appcompat:appcompat:1.3.0) 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\9398b1795b0a45e239a8370198c80687\transformed\appcompat-1.3.0.
> Android resource compilation failed
ERROR:AAPT: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\5b50c60af17e66ade7be3083cf0fe04d\transformed\androidx.appcompat: error: Не удается найти указанный файл. (2).
> Failed to transform core-1.6.0.aar (androidx.core:core:1.6.0) 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\619c06b67a6c841ffa9224727d661a21\transformed\core-1.6.0.
> Android resource compilation failed
ERROR:AAPT: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\308760ecdbed89bb153e932d840e53f3\transformed\androidx.core: error: РќРµ удается найти указанный файл. (2).错误无法转换核心-1.6.0.aar在报告中重复几次,但每次错误文本都是相同的。
我的build.gradle:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'com.shazam.fork'
}
apply plugin: 'com.shazam.fork'
android {
compileSdkVersion 30
defaultConfig {
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}
applicationId "app.converter" // it's ok, nevermind
minSdkVersion 30
//noinspection OldTargetApi
targetSdkVersion 30
versionCode 5
versionName "5"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
vectorDrawables.useSupportLibrary = true
}
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
buildFeatures {
viewBinding true
}
}
}
dependencies {
....
//noinspection GradleDependency
implementation 'androidx.appcompat:appcompat:1.3.0'
....
implementation 'androidx.core:core-ktx:1.6.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
}感谢提前,将提供更多的信息,应要求。
UPD :将-g C:\gradle-cache添加到Jenkins中的gradle任务引发了一个新的错误:
22:14:03 * What went wrong:
22:14:03 Execution failed for task ':app:processDebugAndroidTestResources'.
22:14:03 > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
22:14:03 > Android resource linking failed
22:14:03 C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\ConverterKT\app\build\intermediates\packaged_manifests\debugAndroidTest\AndroidManifest.xml: error: failed to load XML file: РќРµ удается найти указанный файл. (2).UPD 2.将gradle更新为7.5,并显示附加异常,但是在Android中定期运行
21:01:23 FAILURE: Build completed with 2 failures.
21:01:23
21:01:23 1: Task failed with an exception.
21:01:23 -----------
21:01:23 * What went wrong:
21:01:23 Execution failed for task ':app:processDebugResources'.
21:01:23 > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
21:01:23 > Android resource linking failed
21:01:23 C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\ConverterKT\app\build\intermediates\packaged_manifests\debug\AndroidManifest.xml: error: failed to load XML file: Не удается найти указанный файл. (2).
21:01:23
21:01:23
21:01:23 * Try:
21:01:23 > Run with --stacktrace option to get the stack trace.
21:01:23 > Run with --info or --debug option to get more log output.
21:01:23 > Run with --scan to get full insights.
21:01:23 ==============================================================================
21:01:23
21:01:23 2: Task failed with an exception.
21:01:23 -----------
21:01:23 * What went wrong:
21:01:23 Execution failed for task ':app:processDebugAndroidTestResources'.
21:01:23 > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
21:01:23 > Android resource linking failed
21:01:23 C:\Windows\System32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\ConverterKT\app\build\intermediates\packaged_manifests\debugAndroidTest\AndroidManifest.xml: error: failed to load XML file: РќРµ удается найти указанный файл. (2).发布于 2022-08-14 02:54:46
(其中之一) AndroidManifest.xml似乎腐败。可以将<?xml version="1.0" encoding="utf-8"?>写入任何XML文件,而文件本身不具有UTF-8编码功能,这一点也不重要。或者插件id 'kotlin-parcelize'可能是相关的;通常不需要这个插件。除非有充分的理由,否则我也建议把它去掉:
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}虽然它甚至不会在本地建造,但忘了建在Jenkins上吧。
https://stackoverflow.com/questions/73174781
复制相似问题