提问人:Innovations Anonymous 提问时间:6/17/2023 更新时间:6/17/2023 访问量:240
在 Termux 上使用 gradle 构建 Android 应用时出现 AAPT2 错误
AAPT2 error when building an Android app using gradle on Termux
问:
我在 Termux 中安装了 Android SDK。我有一个简单的项目。我让它使用这些说明手动编译,所以我继续使用本教程添加一个联系人选择器,它使用 androidx 依赖项,所以现在我正在尝试使用 gradle 进行编译,因此它管理依赖项。我按照官方文档添加了 gradle 配置。
我运行:
./gradlew clean build
我收到此错误:
Starting a Gradle Daemon, 3 busy and 1 stopped Daemons could not be reused, use --status for details
> Task :app:clean
> Task :app:preBuild UP-TO-DATE
> Task :app:preFreeDebugBuild UP-TO-DATE
> Task :app:mergeFreeDebugNativeDebugMetadata NO-SOURCE
> Task :app:javaPreCompileFreeDebug
> Task :app:generateFreeDebugResValues
> Task :app:checkFreeDebugAarMetadata
> Task :app:mapFreeDebugSourceSetPaths
> Task :app:generateFreeDebugResources
> Task :app:packageFreeDebugResources
> Task :app:createFreeDebugCompatibleScreenManifests
> Task :app:extractDeepLinksFreeDebug
> Task :app:parseFreeDebugLocalResources
> Task :app:processFreeDebugMainManifest
> Task :app:mergeFreeDebugResources
> Task :app:processFreeDebugManifest
> Task :app:mergeFreeDebugShaders
> Task :app:compileFreeDebugShaders NO-SOURCE
> Task :app:generateFreeDebugAssets UP-TO-DATE
> Task :app:mergeFreeDebugAssets
> Task :app:compressFreeDebugAssets
> Task :app:desugarFreeDebugFileDependencies
> Task :app:processFreeDebugJavaRes NO-SOURCE
> Task :app:checkFreeDebugDuplicateClasses
> Task :app:processFreeDebugManifestForPackage
> Task :app:mergeLibDexFreeDebug
AAPT2 aapt2-8.0.0-9289358-linux Daemon #0: Unexpected error output: /data/data/com.termux/files/home/.gradle/caches/transforms-3/9e8f852fb62449ec2d4f2489de052d41/transformed/aapt2-8.0.0-9289358-linux/aapt2[18]: syntax error: unexpected ')'
AAPT2 aapt2-8.0.0-9289358-linux Daemon #1: Unexpected error output: /data/data/com.termux/files/home/.gradle/caches/transforms-3/9e8f852fb62449ec2d4f2489de052d41/transformed/aapt2-8.0.0-9289358-linux/aapt2[18]: syntax error: unexpected ')'
> Task :app:processFreeDebugResources FAILED
> Task :app:mergeFreeDebugJavaResource
> Task :app:mergeExtDexFreeDebug
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processFreeDebugResources'.
> Could not resolve all files for configuration ':app:freeDebugRuntimeClasspath'.
> Failed to transform appcompat-1.6.1.aar (androidx.appcompat:appcompat:1.6.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: /data/data/com.termux/files/home/.gradle/caches/transforms-3/2c78914f4e8a8669078cd47dc84a7b77/transformed/appcompat-1.6.1.
> AAPT2 aapt2-8.0.0-9289358-linux Daemon #1: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
它基本上是拉入它自己的 aapt2 版本,而不是安装在系统上的版本,然后抱怨一个右括号:
Unexpected error output: /data/data/com.termux/files/home/.gradle/caches/transforms-3/9e8f852fb62449ec2d4f2489de052d41/transformed/aapt2-8.0.0-9289358-linux/aapt2[18]: syntax error: unexpected ')'
Termux aapt2 软件包的开发人员/维护者说,我一定是以某种方式将库或可执行文件用于错误的架构。
在我的 GitHub 工作流程中,这部分似乎工作正常,但我收到一个不同的错误,抱怨资源:
> Task :app:preBuild UP-TO-DATE
> Task :app:preFreeReleaseBuild UP-TO-DATE
> Task :app:generateFreeReleaseResValues
> Task :app:mapFreeReleaseSourceSetPaths
> Task :app:generateFreeReleaseResources
> Task :app:createFreeReleaseCompatibleScreenManifests
> Task :app:extractDeepLinksFreeRelease
> Task :app:mergeFreeReleaseResources
> Task :app:processFreeReleaseMainManifest
> Task :app:processFreeReleaseManifest
> Task :app:processApplicationManifestFreeReleaseForBundle
> Task :app:mergeFreeReleaseShaders
> Task :app:compileFreeReleaseShaders NO-SOURCE
> Task :app:generateFreeReleaseAssets UP-TO-DATE
> Task :app:mergeFreeReleaseAssets
> Task :app:bundleFreeReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleFreeReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2ProcessResourcesRunnable
> Android resource linking failed
> Task :app:checkFreeReleaseDuplicateClasses
12 actionable tasks: 12 executed
/home/runner/work/ContactQR/ContactQR/app/build/intermediates/bundle_manifest/freeRelease/AndroidManifest.xml:38: error: resource string/app_name (aka com.innovanon.contactqr.free:string/app_name) not found.
/home/runner/work/ContactQR/ContactQR/app/build/intermediates/bundle_manifest/freeRelease/AndroidManifest.xml:38: error: resource style/AppTheme (aka com.innovanon.contactqr.free:style/AppTheme) not found.
error: failed processing manifest.
是我的构建环境设置不正确,还是我的项目配置不正确?
答: 暂无答案
评论