Reputation: 71
I'm tearing my hair out over here. I've developed applications with earlier versions of nativescript and this has never been issue... This is my last effort before I just downgrade to an older version
I have ran the command tns resources generate icons ../icon.png and it claims to have successfully generated the icons and I can see them in the directory... build and deployed to phone. Still has the default nativescript icon
I went to App_Resources/Android/src/main/res and manually updated the ic_launcher.png file in every mipmap directory... build and deployed to phone, same result! Default icon
Tried deleting the platform/android directory and rebuilding. No luck
I searched from the root directory and I cannot figure out how the heck this default icon is appearing still!!!
Note: I was able to change the splash screen
Any help... please, thank you
Upvotes: 3
Views: 1673
Reputation: 323
If anyone stumble upon this none of the above worked for me, this is what worked on ns 8.4.0
tns resources generate splashes <Path to image>
tns resources generate icons <Path to image>
Update: AndroidManifest.xml
file
Edit: android:icon="@mipmap/logo"
TO android:icon="@drawable/logo"
That it!
Upvotes: 1
Reputation: 451
I had a similar issue on nativescript 8.1.1, nativescript/android 8.1.1 with svelte 3.44.0. After running ns resources generate icons <icon-path>
and ns resources generate splashes <splash-path>
as show in this stack post here. Only the splashes were generated successfully. However the icons didn't work as described, hence I had to generate my app launcher icons using this service. Then I downloaded the zip file, unzipped it and copied the contents of the 'res' directory in the unzipped file to <project-directory>/App_Resources/Android/src/main/res
to replace all the directories with the same names (i.e. mipmap-anydpi-v26, mipmap-hdpi
etc). Then rebuilt and reran my application and everything worked fine.
Upvotes: 3
Reputation: 21
Since 8.x Nativescript ships with the adaptive icons - since the old icons are outdated on more recent android phones, and usually look weird
1.Open a project in Android Studio and in the Project Explorer pane right-click on the app directory or any of the directories inside the app directory. In the context menu that opens select New > Image Asset
2.Once Asset Studio opens you'll see the new default app icon
3.The main thing to know about adaptive icons is that there are two layers, a foreground and background. The default foreground will be titled ic_launcher_foreground.xml and it is an SVG. Go ahead and click the ... button next to the path (image below) and select your app icon that you're going to use.
4.Now you can go ahead and set the other settings for your icon such as trim and the resize percentage. You'll also be able to change the default green background layer, select the Background Layer tab and you can repeat the same process. From experience, in a lot of cases you can use the Color radio button to set the color you'd like to use for your background layer.
5.Once you are finished with your icon configuration you can complete the wizard which will generate the various resources needed for your app. The new files will be located under the android app directory in src/main/res/ where you should see several mipmap- directories.
6.Now move all the files in mipmap- directories to your Nativescript's App_Resources mipmap folder
7.Once you have copied over the newly created icon files to the NativeScript project there is one final change you need for your application. The only change is to set the android:icon value to @mipmap/ic_launcher which is the resource location of the new files we added from the Android project from Android Studio.
Hope this helps to solve your issue
Upvotes: 1
Reputation: 71
I ended up solving this issue eventually, so for anyone this might help in the future... In the newer versions of NativeScript there is now a new folder in res called "mipmap-anydpi-v26" which uses vector graphics. If your on SDK 26+ it will automatically use this vector graphic and IGNORE every other PNG icon in all the other folders.
Your options to remedy this are either:
A) Delete this folder from the directory, which will force it to fall back to the regular PNG icon that's appropriate for the device resolution
B) Edit the file in the folder and update the SVG to use yours
Upvotes: 4
Reputation: 598
I always use NativeScript Sidekick to generate my icons. I don't know if that will yield different results from the tns command, but at least it's something else to try.
Upvotes: 0