在Termux上使用gradle构建Android应用时出现AAPT2错误

tvz2xvvm  于 12个月前  发布在  Android
关注(0)|答案(1)|浏览(216)

我在Termux中使用installed Android SDK。我有一个简单的project。我使用these指令手动编译它,所以我继续使用this教程添加联系人选择器,它使用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.


它基本上是拉入自己的aapt 2版本,而不是安装在系统上的版本,然后抱怨一个右括号:

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 aapt 2包的开发者/维护者说我一定是在错误的架构中使用了库或可执行文件。
在我的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.


我是否错误地设置了构建环境或错误地配置了项目?

e5njpo68

e5njpo681#

res文件夹放在app/src/main中,因此项目结构可能类似于以下内容。

<project-name>
├─ app/
│  ├─src
│     ├─ main
│         ├─ <package-name>
│         ├─ res
│             ├─ <resources>
│  <gradle...etc.>

字符串

相关问题