[英]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.