繁体   English   中英

在 ionic 中构建 android 应用程序时如何解决问题?

[英]How to fix an issue while build android app in ionic?

我在使用 ionic cordova build android 时遇到问题。 如何修复“任务':app:processReleaseResources'执行失败。> Android 资源链接失败authenticator.xml:2: AAPT: error: resource mipmap/icon (aka io.ionic.starter:mipmap/icon) not found. FAILURE : 构建失败,出现异常。

  • 什么地方出了错:

    任务 :app:processReleaseResources FAILED 任务“:app:processReleaseResources”执行失败。 Android 资源链接失败 C:\\ES.eWarrant\\eWarrant\\platforms\\android\\app\\src\\main\\res\\xml\\authenticator.xml:2: AAPT: error: resource mipmap/icon (aka io.ionic.starter:mipmap /icon) 未找到。

    错误:链接文件资源失败。

我知道这是一个老话题,但是如果有人遇到这个问题,我有一个解决方案,如果您使用 ionic native 的 Background Geolocation 插件,那么authenticator.xml 存在问题,这使用 @mipmap/icon 作为 tha 的资源背景中的图标,我解决它的方法是更改​​平台/android 内文件 android.json 中的值,如果您搜索此内容

`{
"res/xml/authenticator.xml": {
        "parents": {
          "/*": [
            {
              "xml": "<account-authenticator android:accountType=\"@string/mauron85_bgloc_account_type\" android:icon=\"@mipmap/icon\" android:label=\"@string/app_name\" android:smallIcon=\"@mipmap/icon\" xmlns:android=\"http://schemas.android.com/apk/res/android\" />",
              "count": 1,
              "mode": "overwrite",
              "plugin": "cordova-plugin-mauron85-background-geolocation",
              "oldAttrib": {
                "android:accountType": "@string/mauron85_bgloc_account_type",
                "android:icon": "@mipmap/icon",
                "android:label": "@string/app_name",
                "android:smallIcon": "@mipmap/icon",
                "xmlns:android": "http://schemas.android.com/apk/res/android"
              }
            }
          ]
        }
      }`

你可以像这样改变它

`
{
"res/xml/authenticator.xml": {
        "parents": {
          "/*": [
            {
              "xml": "<account-authenticator android:accountType=\"@string/mauron85_bgloc_account_type\" android:icon=\"@mipmap/ic_launcher\" android:label=\"@string/app_name\" android:smallIcon=\"@mipmap/ic_launcher\" xmlns:android=\"http://schemas.android.com/apk/res/android\" />",
              "count": 1,
              "mode": "overwrite",
              "plugin": "cordova-plugin-mauron85-background-geolocation",
              "oldAttrib": {
                "android:accountType": "@string/mauron85_bgloc_account_type",
                "android:icon": "@mipmap/ic_launcher",
                "android:label": "@string/app_name",
                "android:smallIcon": "@mipmap/ic_launcher",
                "xmlns:android": "http://schemas.android.com/apk/res/android"
              }
            }
          ]
        }
      }
}`

它就像一个魅力

问候

在为此花费了数小时和数小时后,终于找到了为我的 IONIC 5 项目修复它的正确方法。

第1步。

在您的resources文件夹中创建一个名为icon.png的图像文件。

第2步。

将此行添加到您的CONFIG.XML文件中,在<platform name="android">标记下。

<resource-file src="resources/icon.png" target="app/src/main/res/mipmap/icon.png" />

第 3 步。

然后,删除平台: ionic cordova platform rm android

添加平台: ionic cordova platform add android

准备科尔多瓦: ionic cordova prepare android

构建 android : ionic cordova build android

我认为这将解决这个问题。 谢谢。

解决方案:

作为更正> 创建一个目录: platforms\\android\\app\\src\\main\\res\\mipmap

然后将resources\\splash.png复制到新 mipmap 目录中的icon.png中。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM