capacitor-assets icon indicating copy to clipboard operation
capacitor-assets copied to clipboard

Android: Error occurred while copying

Open johnbwoodruff opened this issue 4 years ago • 49 comments

I am building an Ionic app with capacitor, and am trying to generate the resources as specified in the docs. It works great for iOS and I get all the icons correctly generated. When I run it for android, I get this error. Then when I run my app after a rebuild and sync it only copied the splash screen correctly. The app icon everywhere else is still the default capacitor icon.

This is the error I'm getting:

❯ cordova-res android --skip-config --copy
Generated 18 resources for Android
WARN:   Error occurred while copying resources/android/icon/mdpi-foreground.png
WARN:   Error occurred while copying resources/android/icon/hdpi-foreground.png
WARN:   Error occurred while copying resources/android/icon/xhdpi-foreground.png
WARN:   Error occurred while copying resources/android/icon/xxhdpi-foreground.png
WARN:   Error occurred while copying resources/android/icon/xxxhdpi-foreground.png
Copied 26 resource items to Android

In my resources directory I don't have files with these names. Instead they're named:

resources/android/icon/drawable-hdpi-icon.png
resources/android/icon/drawable-ldpi-icon.png
resources/android/icon/drawable-mdpi-icon.png
resources/android/icon/drawable-xhdpi-icon.png
resources/android/icon/drawable-xxhdpi-icon.png
resources/android/icon/drawable-xxxhdpi-icon.png

Which makes sense why they're not getting copied. Is there possibly something I'm doing wrong? My icon is following the directions. It's in the resources folder called icon.png, and it's 1024x1024. I get no errors with iOS, so I don't think it's something I'm doing wrong, but I'm absolutely not ruling that out.

johnbwoodruff avatar Jul 05 '20 18:07 johnbwoodruff

I have been having exactly the same issue on v0.15.1. This was not an issue on v0.14.0, so I downgraded to that version.

EDIT: I just tried it out and v0.14.0 seems to have its issues as well. The icons don't fit the app circle. I would suggest generating those manually in Android Studio

benjidotsh avatar Jul 05 '20 19:07 benjidotsh

@johnbwoodruff These are just warnings. It's because the copy process expecting generated Adaptive Icon foregrounds, but since you're not using Adaptive Icons, they aren't there. It's fine to ignore, and this won't be an issue by 1.0.0 (see https://github.com/ionic-team/cordova-res/issues/113).

@benjiJanssens I'm not sure what you mean by app circle, but it sounds like a separate issue. Could you create a new issue if the problem persists in the latest version?

imhoffd avatar Jul 06 '20 16:07 imhoffd

This issue is still there.

rajasekarsphcl avatar Aug 18 '20 13:08 rajasekarsphcl

I agree, this is still an issue. This a true problem because the launch app of the icon remains capacitor's picture, in my case.

BenjaminDish avatar Aug 31 '20 15:08 BenjaminDish

I have the same issue

DEGBEMBIA avatar Sep 04 '20 17:09 DEGBEMBIA

same issue here

AdaLollA avatar Sep 08 '20 12:09 AdaLollA

the issue still exists...

gnesher avatar Sep 10 '20 10:09 gnesher

I also encountered the same issue

angelofan avatar Sep 12 '20 15:09 angelofan

the issue still exists...

ketanakbari avatar Sep 15 '20 16:09 ketanakbari

After displaying the warning, the icon of the application is still the logo of the capacitor.

angelofan avatar Sep 16 '20 01:09 angelofan

any body got how resolve this?

I could not make the foreground image. But android studio has an easy option

https://developer.android.com/studio/write/image-asset-studio?hl=es-419

Boel21 avatar Sep 28 '20 00:09 Boel21

How can I remove the standard ionic app icon then? Because the ic_launcher_foreground.png will be generated with the ionic icon instead of my own app icon..

apoth12 avatar Oct 02 '20 13:10 apoth12

I think this should be re-opened. I created a blank starter, added the android and ios platforms, and then did cordova-res with a new icon, which generated the warnings. Project is here: https://github.com/kensodemann/delete-me

You can verify here, for example: https://github.com/kensodemann/delete-me/tree/master/android/app/src/main/res/mipmap-xxhdpi

npx cap open android and then run on a device or emulator and it will use the default cap icon and not the updated tea icon, at least on modern versions of Android. I have not tried on older versions of Android yet.

Seems to be related to this fix: https://github.com/ionic-team/cordova-res/commit/65520bc58d579bf74bb8e9e38a9151a797e29a97 which is copying files that have not been generated even though I have tried generating with and without --type=adaptive-icon

kensodemann avatar Oct 13 '20 18:10 kensodemann

if you generate the ic_launcher_foreground.png with android studio it will overwrite this icon. You dont need to delete or if you want delete manaually. but is unnsecasary

Boel21 avatar Oct 13 '20 19:10 Boel21

Same issue, with a blank ionic/capacitor app.. Ios image splash and icon generates OK, but on android the icon is not replaced and it's still showing the capacitor one. Splash screen works on both ios and android.

Run this: cordova-res android --skip-config --copy

And also got bunch of warnings and icons didn't get replaced:

Generated 18 resources for Android WARN: Error occurred while copying resources/android/icon/mdpi-foreground.png WARN: Error occurred while copying resources/android/icon/hdpi-foreground.png WARN: Error occurred while copying resources/android/icon/xhdpi-foreground.png WARN: Error occurred while copying resources/android/icon/xxhdpi-foreground.png WARN: Error occurred while copying resources/android/icon/xxxhdpi-foreground.png Copied 26 resource items to Android

gregmeszaros avatar Oct 14 '20 19:10 gregmeszaros

@gregmeszaros - follow the instructions here to generate the *-foreground.png files: https://github.com/ionic-team/cordova-res#adaptive-icons

That should at least get you past this, though I believe that we need to get a bit more sorted out in how we handle this, document it, etc. as it is currently not exactly obvious what to do.

Note: you could also generate the adaptive icons via other means if you don't want to follow the linked instructions.

kensodemann avatar Oct 14 '20 19:10 kensodemann

This issue is still there.

Use the following steps to generate. However, you need to create a file as mentioned. Adaptive Icons Android Adaptive Icons are also supported. If you choose to use them, create the following additional file(s):

resources/android/icon-foreground.png must be at least 432×432px resources/android/icon-background.png must be at least 432×432px A color may also be used for the icon background by specifying the --icon-background-source option with a hex color code, e.g. --icon-background-source '#FFFFFF'.

Regular Android icons will still be generated as a fallback for Android devices that do not support adaptive icons.

📝 Note: For Cordova apps, Cordova 9+ and cordova-android 8+ is required. Link: https://github.com/ionic-team/cordova-res#adaptive-icons

sonam-st avatar Oct 21 '20 02:10 sonam-st

This is not clear to me. Can you tell me the steps to avoid this issue?

Sampath-Lokuge avatar Nov 14 '20 15:11 Sampath-Lokuge

Did you create the mentioned files and placed under the named folders? You need to create resources folder if not created

sonam-st avatar Nov 14 '20 15:11 sonam-st

@stNamring Can you tell me how to create those 2 files? I have a resources folder and it has icon 1024x1024 and splash 2732x2732

Sampath-Lokuge avatar Nov 14 '20 15:11 Sampath-Lokuge

@Sampath-Lokuge I have used my same icon file and created icon-foreground.png with the mentioned size. Also, created icon-background.png with the same size with background color of my icon.

sonam-st avatar Nov 14 '20 16:11 sonam-st

@stNamring Can you tell me the other steps also after creating those 2 files?

Sampath-Lokuge avatar Nov 16 '20 11:11 Sampath-Lokuge

@Sampath-Lokuge then, you fire that command to generate resources.

sonam-st avatar Nov 16 '20 15:11 sonam-st

you can do it from android studio, just follow this steps from the developers page: https://developer.android.com/studio/write/image-asset-studio

I've made a short video on how to change the icon https://www.youtube.com/watch?v=QOsDG5RSQ-Q&feature=youtu.be&ab_channel=RockyLon

RockyLon avatar Dec 10 '20 18:12 RockyLon

I've created an icon with the name according to the documentation and in the resources/android/icon folder and then run the command cordova-res android --skip-config --copy

and that doesn't solve the problem.

@stNamring You just copy from the documentation and it doesn't work

aacassandra avatar Dec 19 '20 07:12 aacassandra

I'm also facing the same issue. Did anyone found the solution?

mayankkataria avatar Dec 21 '20 14:12 mayankkataria

Guys, I believe it is a mistake when generating the images using cordova-res, I temporarily solved it as follows:

Go to: resources \ android \ icon

Copy the files: "drawable-mdpi-icon.png" "drawable-hdpi-icon.png" "drawable-xhdpi-icon.png" "drawable-xxhdpi-icon.png" "drawable-xxxhdpi-icon.png"

Paste in the same folder: resources \ android \ icon. ( Dont rewrite )

Rename the copied files to: "mdpi-foreground.png" "hdpi-foreground.png" "xhdpi-foreground.png" "xxhdpi-foreground.png" "xxxhdpi-foreground.png"

I ran the command ionic capacitor sync to synchronize the images, and then ionic capacitor run to run on android.

As I said, it is a temporary resolution, I believe that the way in which images are generated today by cordova-res will be corrected

Renny1 avatar Dec 21 '20 15:12 Renny1

I've created an icon with the name according to the documentation and in the resources/android/icon folder and then run the command cordova-res android --skip-config --copy

and that doesn't solve the problem.

@stNamring You just copy from the documentation and it doesn't work

You may need script to copy if it does not copy to resource folder.

sonam-st avatar Dec 22 '20 05:12 sonam-st

On the plugin page i.e Cordova-res repo , You need to look at this particular section. The adaptive icons are required for Android Platform and you need to put these image at resources\android directory.

image

KumarSunil007 avatar Dec 31 '20 08:12 KumarSunil007

Update, fix?

Hembi avatar Jan 31 '21 16:01 Hembi