Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova/Ionic resources

I'm using ionic to generate resources (icon and splash). I'm using ionic v2.1.0 and cordova v6.4.0.

Until now I've been using (it was working in previous versions):

cordova platform add android
ionic resources

This was adding android with this version:

Adding android project...
Creating Cordova project for the Android platform:
    Path: platforms/android
    Package: ...
    Name: ...
    Activity: MainActivity
    Android target: android-24
Subproject Path: CordovaLib
Android project created with [email protected]

In previous cli versions, ionic resources was generating corresponding entries in config.xml and the resources were placed correctly.

But after upgrading cordova and/or ionic cli, the resources for android have not being copied, so icon and splash remain as cordova ones. I've seen this thread and it says to remove android platform and then use this command:

cordova platform add android@latest

So this adds this platform:

Adding android project...
Creating Cordova project for the Android platform:
    Path: platforms/android
    Package: ...
    Name: ...
    Activity: MainActivity
    Android target: android-25
Subproject Path: CordovaLib
Android project created with [email protected]

And successfully copies the icons and splash. The problem is that this creates an extra res folder:

├── bower.json
├── config.xml
├── gulpfile.js
├── hooks
├── ionic.config.json
├── node_modules
├── package.json
├── platforms
├── plugins
├── res
│   ├── drawable-land-hdpi
│   ├── drawable-land-ldpi
│   ├── drawable-land-mdpi
│   ├── drawable-land-xhdpi
│   ├── drawable-land-xxhdpi
│   ├── drawable-land-xxxhdpi
│   ├── drawable-port-hdpi
│   ├── drawable-port-ldpi
│   ├── drawable-port-mdpi
│   ├── drawable-port-xhdpi
│   ├── drawable-port-xxhdpi
│   ├── drawable-port-xxxhdpi
│   ├── mipmap-hdpi
│   ├── mipmap-ldpi
│   ├── mipmap-mdpi
│   ├── mipmap-xhdpi
│   ├── mipmap-xxhdpi
│   └── mipmap-xxxhdpi
├── resources
├── scss
└── www

So my question are:

  • What is the purpose of this extra generated res folder?
  • Can I safely remove res folder?
  • How can I manage now if I want a different icon for android and for ios? (in older cases I was copying generated resources for android in backup folder, generating new resources for ios and then mixing them and making cordova prepare)
like image 796
Miquel Avatar asked Apr 28 '26 04:04

Miquel


1 Answers

  1. There is no purpose, it's a bug and it should be generated in the platforms/android folder
  2. Yes you can
  3. You can add your splash.png and icon.png to the resources folder if both need to be the same. Add them to resp. resources/android and resources/ios in stead if they need to be different. And then run ionic resources

See below for the solution:

You updated to the latest version of Cordova, but not to the latest version of Android platform. Do this to update to version 6.1.0:

cordova platform update [email protected]

After that the resources will be uploaded to the res directory in platforms/android and you can safely remove the res directory from your project root.

Edit

This issue has been fixed in Cordova 6.5.0.

Update your project to Cordova 6.5.0 using following commands.

npm install -g cordova

If you already have the project built using cordova earlier version you have to update the android platform of your project.

cordova platform update [email protected]
like image 57
JanP Avatar answered Apr 30 '26 16:04

JanP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!