ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

Icons and splash screens generated from `ionic resources` ignored on Android

Open bilalakil opened this issue 10 years ago • 51 comments

Short description of the problem:

Even in a freshly generated project, icon and splash screens generated from ionic resources are being ignored in Android, where the default Cordova images are instead used. This problem does not exist on iOS.

What behaviour are you expecting?

Icons and splash screens generated by ionic resources (which comes up with the Ionic logos if no other icon or splash screen is provided) to be used in the Android app.

Steps to reproduce:

ionic start x
cd x
ionic platform add android
ionic resources
ionic build android
ionic run android

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

The res directory created in the root of the project (following the ionic resources command) contains the expected Ionic logo images (which are created by the ionic resources command as an example) in the many different sizes required by Android.

The platform/android/res directory, however, contains all of the default Cordova images, which appear to be the ones actually being used.

platform/res/android/xml/config.xml perfectly matches the expected config.xml, so it is copying that across as expected, but not the generated images.

Which Ionic Version? 1.7.14

Run ionic info from terminal/cmd prompt: (paste output below)

Your system information:

Cordova CLI: 6.4.0
Gulp version:  CLI version 3.9.1
Gulp local:  
Ionic Version: 1.3.2
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.9.0 
ios-sim version: 5.0.10 
OS: Mac OS X El Capitan
Node Version: v6.6.0
Xcode version: Xcode 8.1 Build version 8B62 

bilalakil avatar Oct 31 '16 01:10 bilalakil

Note that my current workaround to get it built with the icons is to simply move them into the correct position. I do that like so:

mv platforms/android/res/{values,xml} res
rm -rf platforms/android/res
cp -r res platforms/android
ionic build android

However I suspect if I generate a new set of icons or prepare the Android platform again, these steps would be reversed.

bilalakil avatar Oct 31 '16 03:10 bilalakil

I'm also having this exact problem, seems the res map isn't created in the correct location

koenvanzuijlen avatar Oct 31 '16 13:10 koenvanzuijlen

Yes, having the same issue just after updating Ionic and Cordova NPM libraries.

Using Ionic 1.3.2 app

Cordova CLI: 6.4.0
Ionic Framework Version: 1.3.2
Ionic CLI Version: 2.1.4
Ionic App Lib Version: 2.1.2

Update:

Hmm, mine appears to be a bigger issue than that, none of my Plugins (using the Ionic Native library) are no longer loading/found (all is fine for iOS), installed/reinstalled all plugins/platforms etc, strange because I have managed to upgrade fine in the past..

Also to note: Upgraded all Android SDK tools.. Uninstalled and Reinstalled Cordova/Ionic

will investigate further...

** Lastest Update **

So after the various CLI updates. It appears if I use an explicit older android cli platform: cordova platform add [email protected] Fixed the issues with plugins, icons ect, and runs fine.

I have noticed the 'res' folder was appearing (cordova 6) (with the correct iocns) in the root folder of my inital app files, NOT the platform generated folder

So, this should be considered a Cordova issue?

camexapps avatar Nov 01 '16 00:11 camexapps

Hi folks, I have this pb also. I think I know the reason (don't worry it has nothing to do with Illuminatis ;-). The command "ionic resources" updates config.xml. The code written is partly bad code. Instead of "density" inside: It should be "qualifier" as here: Then magically the build process creates the right folders and copy the right files for every screens. So basically the CLI has to be patched (PLZ supa Ionic Team). But for know let's house party: https://www.youtube.com/watch?v=tGJEe-yGLos

workfluo avatar Nov 04 '16 11:11 workfluo

this issue started as soon i upgraded cordova to latest (6.4.0).

kodeine avatar Nov 08 '16 03:11 kodeine

The same problem here with ionic 2 RC2.

jonatastrafaniuc avatar Nov 08 '16 12:11 jonatastrafaniuc

@workfluo thanks man, you solution solved this issue for me. was having this issue as well, my ionic info:

Cordova CLI: 6.3.1 Ionic Framework Version: 2.0.0-rc.1 Ionic CLI Version: 2.1.4 Ionic App Lib Version: 2.1.2 Ionic App Scripts Version: 0.0.39 OS: Node Version: v6.9.1

alfonsojohan avatar Nov 08 '16 23:11 alfonsojohan

I had the same issue with the following system information:

Cordova CLI: 6.4.0 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Framework Version: 1.3.2 Ionic CLI Version: 2.0.0 Ionic App Lib Version: 2.0.0 ios-deploy version: 1.9.0 ios-sim version: 5.0.8 OS: Mac OS X El Capitan Node Version: v4.4.4 Xcode version: Xcode 8.1 Build version 8B62

and my cordova-android version is 6.0.0

I tried the solutions above but none of them worked for me.

Finally I managed to make it work by downgrading Cordova CLI from 6.4.0 to 6.3.1 by running the following command:

npm install -g [email protected]

and removing & adding android platform then re-building for android:

ionic platform remove android
ionic platform add android
ionic run android

Note: In this solution, instead of qualifier I keep using density attribute in config.xml. For example, <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/> or <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>

EmreErdogan avatar Nov 09 '16 03:11 EmreErdogan

If i try: ionic build android i get this: Note: /Users/Workfluo/ionic-server/wad/platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. What does it means? I've got this , the latest version.

workfluo avatar Nov 09 '16 10:11 workfluo

I will try this from ghenry22 in https://github.com/driftyco/ionic/issues/9060: "Upgrade to android platform 6.1.0 and this should be fixed, just updated my project, reran ionic resources and then build and all good."

jonatastrafaniuc avatar Nov 09 '16 12:11 jonatastrafaniuc

I have this: Cordova CLI: 6.4.0 Gulp version: CLI version 3.9.1 Gulp local:
Ionic Framework Version: 2.0.0-rc.2 Ionic CLI Version: 2.1.4 Ionic App Lib Version: 2.1.2 Ionic App Scripts Version: 0.0.39 And i use this for config settings: + BUT in APK the splash screens are named splash. It depends probably on cordova or ionic cli version. Whatever it's unstabil! A MESS!

workfluo avatar Nov 09 '16 13:11 workfluo

I would highly recommend to open the .pkg file with an unzip tool in order to check IF in "res" folder you have any image for splash screens AND their name.

workfluo avatar Nov 09 '16 13:11 workfluo

GET IT. GOTTCHA YOU BUGGY BUG! My solution with a config like: Cordova CLI: 6.4.0 + Ionic Framework Version: 2.0.0-rc.2 + Ionic CLI Version: 2.1.4; is basically: after the Command $ionic resource, in config.xml for all the REPLACE "density" by "qualifier" AND in REPLACE value="screen" by value="splash"

workfluo avatar Nov 09 '16 13:11 workfluo

@camexapps , your solution to do cordova platform add [email protected] worked. NOTE: This is for a cordova backbone app - thought i'd post here since this seems to be more a cordova issue than an ionic issue.

pinindajin avatar Nov 10 '16 22:11 pinindajin

@EmreErdogan your solution solved my problem. Downgrading cordova solves all problems!

For the people reading this, just uninstall the current cordova before installing the older version.

npm uninstall -g cordova
npm install -g [email protected]

rhuanbarreto avatar Nov 11 '16 02:11 rhuanbarreto

Simply because there is no single answer. For me the pb comes not from a plugin or a cordova version. It all about playing with playing with the propriety name "density" vs. "qualifier" and the attribut value "screen" vs. "splash". Than rebuild.

workfluo avatar Nov 14 '16 15:11 workfluo

+1

fonini avatar Nov 16 '16 19:11 fonini

I was able to fix this issue by:

npm install -g [email protected] [email protected]

karser avatar Nov 18 '16 00:11 karser

I found my problem. I created a new ionic test project and the splashscreen is working. So I made a diff between the two config.xml files.

I was using <preference name="SplashScreen" value="splash"/> instead of <preference name="SplashScreen" value="screen"/>.

Thus, I can tell this configuration is working:

  • ionic lib: 2.0.0-rc2
  • ionic cli: 2.1.8
  • cordova: 6.4.0
  • cordova-android: 6.1.0
  • cordova-plugin-splashscreen: 4.0.0

All you have to do is:

  • ionic platform remove android
  • install the correct configuration (cordova, ionic cli)
  • ionic platform add [email protected]
  • ionic resources
  • check you don't have a bad config.xml (see my error)

A valid Android splashcreen config line should look like: <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/>

Hope this helps! :-)

florentsuc avatar Nov 18 '16 10:11 florentsuc

@florentsuc What about the icons? Do they work properly for you? I can't manage to fix it and always get the default cordova icon.

vintage avatar Nov 18 '16 14:11 vintage