简体   繁体   English

运行 ionic cordova build android 时如何修复 AAPT 错误前台活动未找到?

[英]how to fix AAPT error foreground activity not found when running ionic cordova build android?

I recently moved from a Linux to windows environment and I'm having issues building an ionic app successfully.我最近从 Linux 转移到了 Windows 环境,但在成功构建 ionic 应用程序时遇到了问题。 Ionic Cordova build android stops at Ionic Cordova build android 停在

:app:splitsDiscoveryTaskDebug UP-TO-DATE

it seems a plugin (cordova-plugin-paystack) is the cause because it builds fine without errors when I run build with this plugin removed.似乎插件(cordova-plugin-paystack)是原因,因为当我在删除此插件的情况下运行构建时,它可以正常构建而没有错误。

here's the error code:这是错误代码:

:app:compileDebugAidl UP-TO-DATE
:CordovaLib:packageDebugRenderscript NO-SOURCE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
C:\Users\Erondu Emmanuel\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\2a476605aeb8db0b92c43b3475268151\res\values\values.xml:251:5-69: AAPT: error: resource attr/foreground (aka com.kekerides.user:attr/foreground) not found.

C:\Users\Erondu Emmanuel\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\2a476605aeb8db0b92c43b3475268151\res\values\values.xml:251:5-69: AAPT: error: resource attr/foregroundGravity (aka com.kekerides.user:attr/foregroundGravity) not found.

C:\Users\Erondu Emmanuel\Documents\DEVELOPMENT\User\platforms\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:577: error: resource attr/foreground (aka com.kekerides.user:attr/foreground) not found.
C:\Users\Erondu Emmanuel\Documents\DEVELOPMENT\User\platforms\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:577: error: resource attr/foregroundGravity (aka com.kekerides.user:attr/foregroundGravity) not found.
error: failed linking references.

npm version:6.4.1 nodejs :8.12.10 ionic: 5.1.0 cordova :8.0.0 npm 版本:6.4.1 nodejs:8.12.10 离子:5.1.0 科尔多瓦:8.0.0

I have tried the instructions here Cordova Android error :app:transformClassesWithDesugarForDebug when adding plugin and it still doesn't work.在添加插件时尝试了Cordova Android error :app:transformClassesWithDesugarForDebug这里的说明,但它仍然不起作用。

After trying for over 24hrs, I stumbled upon a thread on the Paystack GitHub page here : https://github.com/PaystackHQ/paystack-android/issues/33 .在尝试了超过 24 小时后,我在 Paystack GitHub 页面上偶然发现了一个线程: https : //github.com/PaystackHQ/paystack-android/issues/33

solution: I created a file named attr.xml in Myappname\\platforms\\android\\app\\src\\main\\res\\values\\ and added the following code:解决方案:我在 Myappname\\platforms\\android\\app\\src\\main\\res\\values\\ 中创建了一个名为 attr.xml 的文件,并添加了以下代码:

<declare-styleable name="ForegroundView">
    <attr name="foreground" format="color" />
    <attr name="foregroundGravity" format="integer" />
    <attr name="foregroundInsidePadding" format="boolean" />
</declare-styleable>

and build was successfull!并且构建成功! How do i preserve this file when i run运行时如何保留此文件

cordova platform add android

hopefully this will help someone else in future.希望这会在未来帮助其他人。

Update: For those who are still having this issues after doing as Emmanuel has instructed, do this: there are two Values folders in your app directory.更新:对于那些按照 Emmanuel 的指示操作后仍然遇到此问题的人,请执行以下操作:您的应用程序目录中有两个Values文件夹。 add the above code in both and the error will be gone.在两者中添加上面的代码,错误就会消失。 But if you are using an older version of android studio, you should have only one.但是如果您使用的是旧版本的 android studio,则应该只有一个。

Myappname\\app\\src\\main\\res\\values AND Myappname\\app\\src\\main\\res\\values-21 Myappname\\app\\src\\main\\res\\values AND Myappname\\app\\src\\main\\res\\values-21

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行“cordova build android” - AAPT:错误:找不到资源 android:attr/fontVariationSettings。 \\n android:attr/ttcIndex 未找到 - Running “cordova build android” - AAPT: error: resource android:attr/fontVariationSettings not found. \n android:attr/ttcIndex not found 运行“ ionic cordova build android”命令时,如何解决无效或意外的令牌问题? - How to fix Invalid or unexpected token issue when running “ionic cordova build android” command? 构建和运行时离子 Cordova 错误 - Ionic Cordova Error When Build and Running 使用cordova build --release android时离子构建android错误 - ionic build android error when using cordova build --release android 当我使用此评论时出错 Ionic cordova build android in ionic 9 - error when i use this comment Ionic cordova build android in ionic 9 运行 ionic cordova build android 命令时出现问题 - problems when running the ionic cordova build android command 运行cordova build -release android时出错 - Error when running cordova build –release android 如何修复离子科尔多瓦建立谷歌服务插件的Android? - how to fix ionic cordova build android for google service plugin? 运行ionic cordova build android --prod --release时发生错误 - An error occurred while running ionic cordova build android --prod --release Ionic Cordova Android构建错误 - Ionic Cordova Android build error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM