簡體   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