When I overwrite an image asset in Android Studio, for example the default ic_launcher, the IDE keeps showing the old image - no matter what I do, the image is never refreshed in the IDE (the deployed app uses the correct one). After a while you are not sure which files you have already changed and which are to be changed. You can prepare a list and check the items, but it would be nice to see the actual files in the IDE.
Is there any way to force this incredibly buggy IDE to 'sync' the cached image resources with those actually chosen by the developer?
I am using Android Studio 1.1.
Cheers
Open your src/drawable folder and make sure that this ic_launcher is not in any folder of your drawable, it means that in your mdpi, hdpi, etc... folder is this icon, then you can delete it in each folder on your drawable or you can replace it with yours (with the same name, if you don't want to replace the ic_launcher on the whole code), and Clean / rebuild the project.
Related
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
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
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.
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
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.
I am adding some icons from the drawables folder to a layout. I had an image that I replaced which got the same name as the old one. I have overridden the file, rebuilt the project and the Android Studio's graphical layout showed the new icon. However, when I ran the app, the old icon appeared. I went over all the drawables folders to see if there might be one with the old icon, but it was replaced in every folder. I also tried reinstalling the app and it's still showing the wrong icon.
Why won't the app show the correct icon?
May be due to some bug of Android Studio, Try it out it will work :
Delete .apk from local path manually (Path : \YourProjectFolder\app\build\outputs\apk\app-debug.apk)
then Rebuild Project and finally Run it.
Because of instant run feature,
Once your app is installed, Instant Run allows you to push code changes without building a new APK
new apk is not creating. Try after deleting apk file from path ...\apk\app-debug.apk
Then build and generate apk again.
Rebuild Your Project then it works fine
Delete your icon from the drawables folder, set another image in the application instead of the deleted one, run the application, close the application, add your image again in the drawables folder, add it on your control and run again. It should work now.
What eventually happened is that the images were replaced in a library module, while the app module also contained the old image. Since the app resources overrides the library's resources, the old image was shown.
I feel irritating to develop the xamarin now since it is so not stable... i am intend to create splash screen for the android, however from what i seen from the xamarin documentation,however before i am able to achieve it, i need to add the resources to my project. Please see the following documentation
https://developer.xamarin.com/guides/android/application_fundamentals/resources_in_android/part_1_-_android_resource_basics/
from the beginning the resource folder has been done to create all the mdpi , ldpi those folder... they skipped to teach us how to create those resource folder, so in the end, i tried to create a new folder which is named as drawable-mdpi and put some icon into it. In the end the files and folder name does not exist in the Resource.Designer.cs.
In the end my resources is unuseable... Google no solution
Earlier Xamarin project template used to have all Drawable folders by default. Now the template just has the mipmap folders. You need to create all the drawable folders manually by Right Clicking Resources Folder > Add > New Folder. Give names as "drawable-mdpi" "drawable-hdpi" and so on. You can then add images to them by Right Clicking respective folders > Add > Add Files. If the Image's Id doesn't appear in Resource.Designer.cs file, it might be due to some build error already existing. Try cleaning and re-building. Either Resource Id will appear in Resource.Designer.cs or the already existing error will pop-up fixing which your issue will be resolved.
I realized those documentation is the xamarin old documentation, by the default the xamarin created those folder already, however i dont know why the xamarin don't show when we create the new project and i still dont understand why only create 3 density which is hdpi, xhdpi and the xxdpi, is it the mdpi not longer use? I have no idea. However i will need to add those folder again in the project so i am able to see it.
I recently installed one more Android SDK to Android Studio, the SDK version 4.4 (API level 19), and after using it with my project, it added a set of mipmap folders in the project's res folder (res/mipmap).
I neither understand why, or how to use them.
I read another question about it here on SO.
The answer to it said that:
The mipmap folders are for placing your app icons in only. Any other
drawable assets you use should be placed in the relevant drawable
folders as before.
According to this Google blogpost:
It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions
different from the device’s current density.
I still don't get the reason to this.
Why cant we just place the app icons in the res/drawable folders too?
Also, if only the app icon should be placed in the mipmap folders, how do I create other drawable assets and place them in the drawable folders with the Android Studio Image Asset wizard? (Accessed by right clicking in the project, selecting New > Image Asset)
Why cant we just place the app icons in the res/drawable folders too?
Oh, you can. Google doesn't recommend it, that's all.
Quoting myself from Version 6.5 of my book:
While
drawable resources might be removed when packaging an APK, such as for the
Gradle for Android split system for making density-specific editions of an app,
mipmap resources are left alone, apparently
This is because launcher icons may be pulled from a higher-density bucket than the regular device density that is used for all other drawables. Putting them in res/mipmap-*/ directories means that we won't inadvertently get rid of them as part of optimizing APK size.
(why they didn't handle this in a better way, I have no idea)
how do I create other drawable assets and place them in the drawable folders with the Android Studio Image Asset wizard? (Accessed by right clicking in the project, selecting New > Image Asset)
The Image Asset wizard only puts launcher icons in res/mipmap-*/ directories. If you choose the other icon types, they will go in res/drawable-*/. And, of course, the Image Asset wizard itself is optional.
I'm trying to change the background of my first app to a png I have. I put the png in a newly created folder called "drawable." When I go to browse my "drawable" I can't see it's "children" or files. The only error of sorts that it gives me is "You must... rce item" anyone run into this? Android API 7 by the way.
Put the png in /res/drawable and then do a clean on your project in eclipse to force the .R class for your app to be recreated. You might also need to do an f5/refresh in eclipse on the project to get it to see that you have added a file in filesystem to /res/drawable.