How to change android app icon and splash screen?

How to change android app icon and splash screen?

by Zonair Gillani -
Number of replies: 3

Hi,

I am developing a customized moodle app. I have setup the environment for development. I have run the app in android studio and after building the apk file, I have run the app in my mobile as well.

But the icon and splash screen of the app have not been changed. I tried to find out the image location for icon/splash but i was unable to find out that.

If anyone can help me out to tell me, how can i change icon and splash screen?


Thanks,

Syed Zonair

Average of ratings: -
In reply to Zonair Gillani

Re: How to change android app icon and splash screen?

by Godwin France -

Hello, have you been able to figure this out ?

In reply to Godwin France

Re: How to change android app icon and splash screen?

by Zonair Gillani -
Hi Godwin France!

Here is my documentation regarding the solution.

A. Get Resources
## At this step, you will get the icons and splash images generated for each android phone.
## You will get the folders of icons and splash images in "/platforms/android/app/src/main/res" folder.

1. Replace "icon.png" file in "./resources" with your "icon.png".
## The size of icon.png should be same as 1024*1024
## This will be the icon of your app.

2. Replace "splash.png" file in "./resources" with your "splash.png".
## The size of splash.png should be same as 2732*2732
## This will be the splash image of your app.

3. Replace "icon-background.png" and "icon-foreground.png" files in "./resources/android" with your files.
Alternative:
a. You can copy and paste your "icon.png" file from "./resources" two times.
b. And rename those files as "icon-background.png" and "icon-foreground.png".
c. Make the background as transparent; as original "icon-foreground.png" file has.

4. Create following four files as your icon files in "./resources/android/icon" folder:
1. drawable-hdpi-smallicon.png
2. drawable-ldpi-smallicon.png
3. drawable-mdpi-smallicon.png
4. drawable-xhdpi-smallicon.png

5. npm i -g cordova-res
## This will install cordova-res on your PATH globally.
## You cannot generate resources without cordova-res installed.

-----
Note:
If you will recieve an error like:
ERR! sharp EACCES: permission denied, open '/root/.nvm/versions/node/v11.15.0/lib/node_modules/cordova-res/node_modules/sharp/5985-libvips-8.9.1-linux-x64.tar.gz'
gyp ERR! stack Error: EACCES: permission denied, mkdir '/root/.nvm/versions/node/v11.15.0/lib/node_modules/cordova-res/node_modules/sharp/build'

then
npm install -g cordova-res --unsafe-perm
"--unsafe-perm" flag is used to open permissions for you.
-----

6. cordova-res
## This will generate resources for android platform.

-----
Note:
If you will get the following error:
ERROR: Missing source for "adaptive-icon" (sources: resources/android/icon-background.png, resources/android/icon-background.jpg, resources/android/icon-background.jpeg)

then
get a "icon-background.png" in "resources/android/".
Like:
I duplicated the "icon-foreground.png" and rename it as "icon-background.png".
-----

## You will get following output:
Generated 24 resources for Android
Generated 47 resources for iOS
Wrote to config.xml

## This will generate
A. Generated 24 resources for Android
a. 6 files with "drawable" name in "resources/android/icon" folder.
b. 6 files with "background" and "foreground" name in "resources/android/icon" folder.
## As "icon-background.png" and "icon-foreground.png" are the same files with different names that is why they are considered as one.

c. 12 files in "resources/android/splash" folder.

B. Generated 47 resources for iOS
a. You will have a new folder "ios" in "./resources".
b. 28 files in "./resources/ios/icon" folder.
c. 19 files in "./resources/ios/splash" folder.

B. Create Platforms
1. npm update -g cordova
2. npm update -g ionic

3. platforms:
For Android:
ionic cordova platform remove android

-----
Note:
If you will get the following error:
EBUSY: resource busy or locked, unlink 'I:\Moodle Project\moodleapp\platforms\android\app\google-services.json'

then
Close the application that is using this file or try to move the file from that location.
-----

ionic cordova platform add android
a. This will generate a folder "./platforms/android".
b. Then this will run two commands:
ionic cordova resources android --force
cordova-res.cmd android
## This command will generate icons and splash images with your provided resources "./resources" in "/platforms/android/app/src/main/res" folder.

For Ios:
ionic cordova platform remove ios
ionic cordova platform add ios

-----
Note:
If you will get
"Type-error" or "add android" command is not working

then
npm uninstall -g @ionic/cli
npm cache clear --force
npm install -g @ionic/cli@6.9.1
npm i -g @ionic/cli
npx ionic cordova platform add android
-----

4. ionic cordova platform
## This will show you that you have the platform or not.
Average of ratings: Useful (2)